• Resolved ipedigo

    (@ipedigo)


    Hi- I’m trying to set a default membership level for each person that registers to my site. I found this code snippet from a previous thread, but it doesn’t seem to work for me. The default ID I’m trying to use is 7.

    function my_pmpro_default_registration_level($user_id) {
    //Give all members who register membership level 7
    pmpro_changeMembershipLevel(1, $user_id);
    }
    add_action(‘user_register’, ‘my_pmpro_default_registration_level’);

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ipedigo

    (@ipedigo)

    I should add, I’m using BuddyPress with the PMP add-on integration. If I manually add the new user to the membership level I’ve setup, they are allowed access to the restricted pages. But, if I tried this code in Cope Snippets, there is no result.

    Thread Starter ipedigo

    (@ipedigo)

    I discovered this function also. I thought since it targets the WP role, then it should automatically assign the designated membership level ID. No luck with this either. Must be doing something wrong.

    <?php
    function assign_pmpro_level_to_role($user_id, $role, $old_roles)
    {
    global $current_user;
    //checks if the user doesn’t have a membership level yet
    if(!$current_user->ID) {

    //we found a role related to pmpro level
    if($role == “subscriber”)
    {
    pmpro_changeMembershipLevel(7, $user_id); //gives default customers the level 7 free registration membership
    }
    elseif($role == “administrator”)
    {
    pmpro_changeMembershipLevel(10, $user_id); //gives admin role registrants the all access level 10 membership
    }
    }
    }

    add_action(‘set_user_role’, ‘assign_pmpro_level_to_role’, 10, 3);

    Plugin Author Andrew Lima

    (@andrewza)

    Hi @ipedigo

    Please can you adjust the change your initial code snippet shared from pmpro_changeMembershipLevel(1, $user_id); to pmpro_changeMembershipLevel(7, $user_id); which should work.

    This code should set the user’s default level whenever they register on the frontend of your site outside of the Paid Memberships Pro checkout page, such as the default WordPress registration page.

    If you need further assistance with this, please reach out on http://www.paidmembershipspro.com or find a local WordPress developer that may assist you in tweaking or troubleshooting this code further as our support scope on WordPress.org does not cover customizations to gists/code recipes.

    We are more than happy to discuss this on a higher level and recommend any hooks, or functions you may use to achieve your desired customizations.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Default Membership Level’ is closed to new replies.