Applying two user levels through one registration.

Has anyone had any success with Membership 2 and applying two levels through a single registration?

I need to set up multiple variations and am looking for a solution. In membership pro 1 I was able to have users register for one level and then I had to manually add the variant it was suggested to me that membership pro 2 could handle this automation any help on making this possible would be greatly appreciated.

  • Kasia Swiderska

    Hi Matt,

    Can you tell me if this multiple memberships should be applied to all users that registered on you site and didn't choose any subscription? And they have no ability to choose after that, more subscriptions by themselves?
    In Membership 2 Pro after registration all users are provided by the list of all subscriptions that they can join - if the subscriptions are free, then it's just one click for members to join.
    Please, tell me more about that and I will try to find a solution.

    Kind regards,
    Kasia

  • Matt

    HI Kasia,
    Thanks for the quick response. I think I'm in a bit of "still figuring it out" phase of our Dev site. (Our Live site is http://www.pa-connect.org our dev-site is http://www.dev.pa-connect.org ) I believe that I we have about four groups that will interact on our site. The first are visitors with limited access to about 5% of our site and content. The Second are free users no payment just contact info able to view roughly 25% of our content. The third are Paid users who provide contact info and a small annual fee with access to about 60% of our content. The last which has the most potential for growth on our site and has access to the same content as our paid users and an additional 10% of specific content.

    We are moving our open enrollment courses from our marketing site. http://www.project-adventure.org and automating them on our pa-connect site. In the past participants have been sent print publications once they register for a workshop. Now that our content membership site is fully functional we'd like to add the ability for our customers who register for a workshop to also have access to pa connect.

    In my head all I need to do is create a new standard level called workshop a with the price structure that we have determined hit go. The problem I am having is that when the majority of our content is set up for our "paid level" and the user has registered for "a level" the user will not see the "paid level" content they will only see the "a level" content.

    Now I am thinking that I need to have membership pro 2 set so that when the "a level" user registers for "workshop a" they are automatically registered for "paid level" too.

    Are you able to follow?
    Thanks -Matt

    • Kasia Swiderska

      Hi Matt,

      Ok, I think I understand. So - there is no way that user can join multiple subscriptions at once, without the additional code for that. I will ask one of my colleague if this can be done with some quick code snippet.
      But - you can add multiple memberships protection to your content. So for example: if you have this one membership level for workshops, then you can protect with this level also the content that is available for "normal" paid users. When you do that - they will have access to that content also.
      This is approach from the other way - don't give users multiple membership, but use multiple memberships level to protect content.
      How does it sounds?

      Kind regards,
      Kasia

    • Kasia Swiderska

      Hi Matt,

      My next question is if the [not-level] shortcode works in membership pro 2?

      No, Membership 2 pro have it's own set of shordoces. Y0u can check them in Membership 2 -> Help -> Shortcode tab.
      Basically in M2Pro plugin the not-level is the "default" type if subscription and have it's own ID, that can be used with the

      [ms-protect-content id="1"] Only members of membership-1 can see this! [/ms-protect-content]
      shortcode.

      You can use it also in that way

      [ms-protect-content id="2,3" access="no" silent="yes"] Everybody except members of memberships 2 or 3 can see this! [/ms-protect-content]

      Kind regards,
      Kasia

  • Ash

    Hello @Matt

    I hope you are well today.

    Please try the following code:

    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 ) {
    	$target_membership = '';
    	switch( $membership_id ){
    		// if first membership 123
    		// then assign to 456
    		case 123:
    			$target_membership = 456;
    			break;
    
    		// if first membership 321
    		// then assign to 654
    		case 321:
    			$target_membership = 654;
    			break;
    
    		//and so on...
    	}
    
    	$member = MS_Factory::load( 'MS_Model_Member', $user_id );
    	$subscription = $member->add_membership( $target_membership );
    
    	if ( $member->has_membership() ) {
    		$member->is_member = true;
    	} else {
    		$member->is_member = false;
    	}
    	$member->save();
    }

    It's an example code. For first block, if registered membership ID is 123, then 456 ID membership will be assigned too. For second block, if registered membership ID is 321, then 654 ID membership will be assigned . You need to edit the code and match the correct membership IDs.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    You can download the code from here too: https://gist.github.com/bappi-d-great/66db952e10028ed6f635

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash