• Resolved Anonymous User 8455164

    (@anonymized-8455164)


    Is it possible to add a capability to users who are also paid members? If I have to make my own solution, could someone make an outline of the steps my solution would have to accomplish to do this?

    I’m new to WordPress’ roles & capabilities. Thanks for your help!

    http://wordpress.org/extend/plugins/paid-memberships-pro/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jason Coleman

    (@strangerstudios)

    Cameron,

    This isn’t built into the plugin, but is easy enough to do using hooks we added.

    I wrote something up on our site behind the support pay wall (http://www.paidmembershipspro.com/2011/10/give-new-members-author-role/) but here is the crucial part pasted.

    Add something like this to your functions.php:

    /*
    	This code will make members signing up for membership level #1 authors and make them subscribers when they cancel.
    */
    function my_pmpro_after_change_membership_level($level_id, $user_id)
    {
    	if($level_id == 1)
    	{
    		//New member of level #1. If they are a subscriber, make them an author.
    		$wp_user_object = new WP_User($user_id);
    		if(in_array("subscriber", $wp_user_object->roles))
    			$wp_user_object->set_role('author');
    	}
    	else
    	{
    		//Not a member of level #1. Ff they are an author, make them a subscriber.
    		$wp_user_object = new WP_User($user_id);
    		if(in_array("author", $wp_user_object->roles))
    			$wp_user_object->set_role('subscriber');
    	}
    }
    add_action("pmpro_after_change_membership_level", "my_pmpro_after_change_membership_level", 10, 2);
    Plugin Author Jason Coleman

    (@strangerstudios)

    Thread Starter Anonymous User 8455164

    (@anonymized-8455164)

    Thanks! This helps a lot! I was hoping I could just add a specific capability to certain users without affecting their role, but it appears WordPress doesn’t inherently work that way. Ah well, I can just add a new role.

    Thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Paid Memberships Pro] Adding Capabilities to Paid Members’ is closed to new replies.