Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello!
    Thank you for using Paid Memberships Pro. From what I understand, you would like to offer free membership to your existing customers? You can do this using a discount code, and restrict sign ups to only those you give the code to by using the code gist found here:

    https://gist.github.com/strangerstudios/5573829

    You will need to modify the code slightly to set the level id and the coupon code. You can then paste the gist into your theme’s functions.php file. Only those you provide the code to will be allowed to sign up. Hope this helps. Please let us know if you have any further questions. Thanks again.

    Thread Starter Paula Atherill

    (@paula-atherill)

    Hey, thank you so much for your reply. Apologies, I only work part time…

    This is EXACTLY what I was looking for.

    I am not a coder. Can you highlight the bits I need to add in and where to the code? I have generated a discount code and know which level to apply it to. Just not sure where to put the info and in what form.

    I have copied and pasted the text into the functions.php area. Good start ??

    Thank you so much for your help!

    Great H-master

    (@great-h-master)

    Hello! In your WordPress admin area go to Memberships >> Membership Levels and note the Level ID you want to restrict access to. Then from the link above replace lines 14 and 15 with the following:

    if($pmpro_level->id == YOUR LEVEL ID && (empty($discount_code) || $discount_code != "REQUIRED_CODE")) //use this conditional to check for a specific code.

    Change the “YOUR LEVEL ID” to the level ID you noted, and change the “REQUIRED_CODE” to the code you generated. Take the edited code gist and add it to your theme’s functions.php file and it should work. Let u know if you need any help. Thanks again.

    Thread Starter Paula Atherill

    (@paula-atherill)

    Hey there,

    Thank you for posting this. I followed the instructions you provided.

    When I went to save it, the whole site went down.

    I cant login to wordpress to take the code out again.

    Any ideas?

    I just get a white screen when I go to the webpage or wordpress login.

    Thread Starter Paula Atherill

    (@paula-atherill)

    Hey there,

    It came back up somehow! I didnt touch it ??

    Hopefully last question.

    It is posting about using a discount code but it still lets me sign up without it.

    What can I do to change that?

    Thread Starter Paula Atherill

    (@paula-atherill)

    My web developer fixed it apparently! They took out the code and it came back up.

    Any idea why the code would crash the site? Any alternatives I can try?

    Great H-master

    (@great-h-master)

    Hello. Good to hear your site is back up. Did you paste the entire code gist or just the one line above? If you only pasted the one line above try this…remove that one line and paste the following code into your theme’s functions.php file:

    /*
      Only let members for a certain level sign up if they use a discount code.
      Place this code in your active theme's functions.php or a custom plugin.
    */
    function my_pmpro_registration_checks_require_code_to_register($pmpro_continue_registration)
    {
      //only bother if things are okay so far
    	if(!$pmpro_continue_registration)
    		return $pmpro_continue_registration;
    
    	//level = 1 and there is no discount code, then show an error message
    	global $pmpro_level, $discount_code;
    
      if($pmpro_level->id == YOUR_LEVEL_ID && (empty($discount_code) || $discount_code != "REQUIRED_CODE")) //use this conditional to check for a specific code.
      //if($pmpro_level->id == 1 && empty($discount_code))
    	{
    		pmpro_setMessage("You must use a valid discount code to register for this level.", "pmpro_error");
    		return false;
    	}
    
    	return $pmpro_continue_registration;
    }
    add_filter("pmpro_registration_checks", "my_pmpro_registration_checks_require_code_to_register");

    You should replace the YOUR_LEVEL_ID with the level ID you wish to restrict and replace the REQUIRED_CODE with the discount code you associated with the level. Let us know if this helps. Thanks again.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Free Membership – can I restrict access?’ is closed to new replies.