Auto Add user to Membership Level?

Is there a way to automatically add a user to a membership level?

For example:
Tier 1 = all non logged in users
Tier 2 = logged in users

So when a user registers in the system they are automatically added to Tier 2

Is this possible?

  • Tyler Postle

    Hey Judah,

    Thanks for your question :slight_smile:

    Right now, any content that isn't protected is available to free members so that is sort of like the default tier to non logged in users. Anything that isn't protected. You can also use shortcodes to show stuff only to non-logged in visitors. Like this:

    [ms-user type="guest"]
    only a non logged in visitor can see this.
    [/ms-user]

    You can also use type="loggedin" for any logged in user and then 'admin' or 'all'.

    To see more about the shortcodes you can visit: Protect Content > Help > Shortcodes. From your dashboard.

    To automatically assign them a membership on sign up you can use the membership registration form shortcode:

    [ms-membership-register-user membership_id="5"]

    Replace the "5" with the membership ID of your choosing :slight_smile:

    Hope this helps! Let us know if you have any further questions.

    All the best,
    Tyler

  • Judah

    Hey @Tyler Postle,

    Thank you for getting back to me.

    When it comes to the membership registration. As of now, the users register in the system via buddypress. Will that shortcode work if that is where I want them to sign up/register in the system?

    Pretty much I have a page where only registered users can access (but don't have to pay for). I want the system to be able to automatically add them to the tier that that relates to.

    I am currently playing around with the membership plugin and am finding it much easier to accomplish what I am trying to do.

    Please let me know about the shortcode and if it will work for BP registrations.

  • Ash

    Hello @Judah

    I hope you are well today.

    To assign a membership on registration, please try the following code:

    add_action( 'user_register', 'add_membership_on_register', 10, 1 );
    function add_membership_on_register( $user_id ) {
    	// Give the membership ID here
    	$mem_id = 28;
    	$mem = new MS_Controller_Member();
    	$mem->member_list_do_action( 'add', array( $user_id ), $mem_id );
    }

    You need to give the membership ID in $mem_id variable.

    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.

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

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.