@stephenfourie,
It seems that any other plugin or code is doing it.
This plugin won’t assign role never as default for users.
@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?
@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.
@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.
@stephenfourie,
Thanks for solving the mystery.
I will add a not for this cases.
Kind regards,
Javier
Did it 🙂
If you have one minute please leave a good review or make a little donation.
@carazo thanks 🙂 I’ve added my 5 star review. Will see about a small donation too if we can.