• Resolved stephenfourie

    (@stephenfourie)


    Hi there,

    We’re trying to do a user import with a custom role, but the user role always gets set to Administrator.

    We’ve tried setting the ‘Default Role’ to both the custom role, as well as ‘Subscriber’ or ‘Editor’. We’ve also tried setting the role in the CSV file using the column ‘role’. None of this makes any difference, it always ends up setting the user as Administrator.

    What’s odd is that this worked fine on a test site, and it we did previously run an import of over 700 users which worked fine.
    I’m not sure what’s changed.

    We also tried using the previous version of the plugin, thinking that would make a difference – but no change.

    There must be something interfering, but we don’t know what. The error and debug logs aren’t showing anything useful either.

    Any idea how we can fix this?

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

    (@carazo)

    @stephenfourie,

    It seems that any other plugin or code is doing it.

    This plugin won’t assign role never as default for users.

    Thread Starter stephenfourie

    (@stephenfourie)

    @carazo the plugin works fine on a separate test site, and correctly assigns our custom role ‘Bronze’.

    The problem is, it doesn’t matter what we select as ‘Default Role’ in the import settings, it always sets it as administrator.

    And there is nothing in the logs to show why.

    Can you maybe tell me what code to look for to try find out what other plugin might be interfering? Is there a specific hook or action I can look for?

    Plugin Author Javier Carazo

    (@carazo)

    @stephenfourie,

    There is no hook for this (I cannot remember).

    The role is assigned in the standard way.

    Maybe other plugin is doing also the same task (assign the job) but after creating the user, so we cannot execute nothing when the import finish.

    Thread Starter stephenfourie

    (@stephenfourie)

    @carazo thanks for your quick responses.

    Your comments made me think about how your code is working, and I edited the plugin to add error_log comments at each step.

    Eventually I found that your plugin does not set roles for my user imports if the user is an administrator.

    This lead me to check why the user is admin if not from your plugin.

    Turns out, someone had set the default user under Settings -> General -> New User Default Role to Administrator.

    This effectively means that your plugin will not set the role, because the user was created as an admin.

    So I changed this setting, and your plugin now works perfectly.

    Perhaps you can make a note of this in the plugin documentation? If the default new role is administrator in WordPress settings, role will not be set during a csv file import.

    Plugin Author Javier Carazo

    (@carazo)

    @stephenfourie,

    Thanks for solving the mystery.

    I will add a not for this cases.

    Kind regards,

    Javier

    Plugin Author Javier Carazo

    (@carazo)

    Did it 🙂

    If you have one minute please leave a good review or make a little donation.

    Thread Starter stephenfourie

    (@stephenfourie)

    @carazo thanks 🙂 I’ve added my 5 star review. Will see about a small donation too if we can.

    Plugin Author Javier Carazo

    (@carazo)

    Thanks!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘User Role Always Set as Administrator’ is closed to new replies.