Programatically changing user roles
-
My predecessor had new users created and given a custom role, called “Blog Owner”. In wp_usermeta, for the record ‘wp_blogid_capabilities’, the value is ‘a:1:{s:5:”owner”;b:1;}’. I want to change it to ‘a:1:{s:13:”administrator”;b:1;}’. I know I could do a MySQL UPDATE query, but I’d rather do it programatically within WordPress using their functions.
I first query wp_usermeta for every record with the ‘owner’ value (9305 results returned), and I then pull the blog_id out of the meta_key (i.e., wp_23_capabilities). What would be the best way to update the users’ role in the associated blog_id?
Sorry if this doesn’t explain it well. Let me know if you have questions.
The topic ‘Programatically changing user roles’ is closed to new replies.