Membership Member Capabilities addon not working

I'm trying to give each new member their own role depending on the membership they signed up from using the Member capabilities addon but it's not working, the users always have the default role of subscriber.

  • Oguz
    • QA Engineer

    Hey Logan Stark ,

    Hope you're doing well today.

    You can use this code to make that you want;

    add_action( 'ms_model_relationship_create_ms_relationship_before', 'ms_controller_member_assign_memberships_done_cb', 99, 4 );
    function ms_controller_member_assign_memberships_done_cb( $membership_id, $user_id, $gateway_id, $move_from_id ) {
    	$user = new WP_User( $user_id );
    	switch( $membership_id ){
    		case 99:
    			$user->set_role( 'editor' );
    		case 185:
    			$user->set_role( 'author' );
    		case 553:
    			$user->set_role( 'subscriber' );

    You need to change "case (number)" parts. That numbers are membership id's. You can find that Memberships > Shortcode > Show;

    Change numbers, prepare your code and paste in functions.php of your theme (or child theme). If you’re not sure how to do this or require assistance please tell us and I will explain the steps more or I will do that for you.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.