Apply membership level to all existing users

How can I apply a membership level to all existing users ?

I don't want to go page by page doing the bulk thing in 80 pages, I need to apply all the users the same level in one click.

How ?


  • Vaughan


    unfortunately i don't think this is possible.

    you can increase the maximum users that is displayed in the list so you can bulk add. but that's about it.

    i thought maybe it could be done with an SQL query in the DB, but it would be rather complex. as you would need to add specific things in certain tables. and a membership key (which is a hash key) in the users table for each member (i'm not sure what process is used for that membership key)

    then grab each user id and add them to the membership_relationships table linking them with each subscription & level id aswell as the payment gateway etc.

    i'm not sure what else to suggest, let me just ping @marko to see if he can suggest anything.

    hope this helps a little.

  • Marko Miljus

    Hi @polle,

    Here is the possible solution. Add this code in the Membership plugin.

    1.) Open main file membershippremium.php and put this code bellow everything there:

    //Function to add a level to all users
    function membership_set_level_to_all_users($level_id) {
        if (!ini_get('safe_mode')) {
            set_time_limit(0); //handy if you want to process large number of users
        $users_args = array(
            'blog_id' => $GLOBALS['blog_id'],
            'role' => '',
            'meta_key' => '',
            'meta_value' => '',
            'meta_compare' => '',
            'meta_query' => array(),
            'include' => array(),
            'exclude' => array(),
            'orderby' => 'login',
            'order' => 'ASC',
            'offset' => '',
            'search' => '',
            'number' => '',
            'count_total' => false,
            'fields' => 'all',
            'who' => ''
        $users = get_users($users_args);
        foreach ($users as $user) {
            $member = new M_Membership($user->ID);
            $tolevel_id = (int) $level_id;
            if ($tolevel_id) {
                if (!$member->has_level($tolevel_id)) {

    Add this line bellow the function:

    membership_set_level_to_all_users(PUT YOUR LEVEL ID HERE);

    Replace the text of the argument with actual level id you want to add to all users. If you don't know level id, just go to the "Access Level" link within the admin, and click edit link bellow the level name. You should get the url like this .../wp-admin/admin.php?page=membershiplevels&action=edit&level_id=1

    level_id value is one we need.

    3.) Just reload or go to the, for instance, All Members page and wait. If you have 1000 users or more, this operation will be time consuming.

    Let me know does it work for you.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.