Support » Plugin: Import and export users and customers » Hi, existing user’s roles are not updating

  • Resolved RickHN

    (@rchinchilla)


    Hi, I’ve tried several times but existing users ‘role’ are not working as it’s intend.

    MY GOAL:
    Add the ‘instructor’ role to existing users in a bulk with this plugin.

    This is the way I tried:

    CSV FILE (example):
    ——————————-
    Username,Email,Password,role
    John Smith,john@smith.com,,
    Mary Johnson,mary@gmail.com,,
    … and so on

    PLUGIN SETTINGS:
    ———————————
    -Default role: instructor (custom role)
    -What should the plugin do with empty cells?: Leave the old value
    -Update existing users?: YES
    -Update roles for existing users?: Yes, add new roles and not override existing ones

    RESULTS:
    ——————————————–
    Always adding default role but deleting old existing ones.

    I DID TRY ALSO…
    ——————————————————
    -Update roles for existing users?: NO
    but always overriding existing roles with default role.

    *INFO:
    ———————————————————–
    All the CSV file are already existing users, I’m not including new users.

    Your import documentation says “If you create a column called ‘role’: if cell is empty, roles would be chosen from ‘Default role’ field in import screen;”

    So, I created a empt role column in CSV and define a default role in import screen and set to [Update roles for existing users?: Yes, add new roles and not override existing ones ] BUT still overriding users roles with default role choosen.

    ¿Some advice please?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Javier Carazo

    (@carazo)

    @rchinchilla,

    Your user must have 1 role or more than 1 role?

    Only instructor?

    Thread Starter RickHN

    (@rchinchilla)

    ¡Thanks for quickly response Javier!

    The existing users have one, two and even three roles in some cases.

    What I want is use your plugin to bulk adding the ‘instructor’ role to all those existing users.

    • This reply was modified 4 years, 11 months ago by RickHN.
    Plugin Author Javier Carazo

    (@carazo)

    WordPress does not allow more than one role per user (although under the hood it can be done).

    So the problem probably will be there.

    Thread Starter RickHN

    (@rchinchilla)

    Mmmm… so why the plugin settings have the options to:

    A) Check more than one Default Role field in import screen.

    B) Update roles for existing users?:
    1. NO but always overriding existing roles with default role.
    2. YES, add new roles and not override existing ones.
    (None of these options are working)

    C) The plugin settings and documentation tab says “If you create a column called ‘role’: if cell is empty, roles would be chosen from ‘Default role’ field in import screen.” (Use the plural “roles” all the time?).

    ????????

    Can you explain me this please?

    • This reply was modified 4 years, 11 months ago by RickHN.
    Plugin Author Javier Carazo

    (@carazo)

    WordPress does not allow to use more than role, but yes, the plugin manage roles as a list:

    if( is_array( $role ) ){
    	foreach ($role as $single_role) {
    		$user_object->add_role( $single_role );
    	}	
    }
    else{
    	$user_object->add_role( $role );
    }

    So it should work with more than one role.

    Which can be your problem? If you read the code, you will find that:

    • If a role column is found
    • Default roles will be completely ignored

    So you have to:

    1. Use only default roles and forget the role column
    2. Use the role column, and forget the default roles
    3. Remember that you cannot insert an array directly in the cell, so if you use the role column you will only be able to use “one role”.

      Also, remember that role in cells have to be slug of the role, sometimes you are using any other kind of identifier instead the role slug and in this cases, it won’t work.

      Remember this is free software and you get it without paying, we use much hours to do this plugin and also to answer this support, so if you have some way to help us to improve it (new code or a little donation) it will be highly appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hi, existing user’s roles are not updating’ is closed to new replies.