1

I have 2058 users who are contributors. I need to convert their role to author.

How can do it by SQL?

1

1 Answer 1

0

I recommend backing up the database before making any major/bulk changes to it.

First you need to get all users with the role "contributors", then update their roles to "author".

$contributors = get_users(array('role'=>'contributor'));

foreach($contributors as $contributor){

    wp_update_user(array( 'ID' => $contributor->ID, 'role' => "author") );

}
echo "done updating contributors to authors";

You could have this script on an empty page template. Just load the page once, for the script to run. Then disable the script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.