问题
I'm working on a Wordpress website having this bug : 9000 users should be "subscriber" (Wordpress role), but they have no role assigned now (probably due to a users import script) :
Image : http://i.imgur.com/GulqggZ.jpg
In the meta_value, we can see their name instead of the role : Dupont, Maurice ... How can I assign the role/capability "subscriber" to all users without role ?
I found a plugin doing this in bulk but it cannot handle more than 1000-2000 users and the link for download is broken.
Many thanks in advance
回答1:
You can do this with a single query. Please check before running that a:1:{s:13:"administrator";b:1;}
is the only value than need to be preservered. If there is others, add them in the query conditions.
UPDATE wp_usermeta
SET meta_value = 'a:1:{s:10:"subscriber";b:1;}'
WHERE
meta_key = 'wp_capabilities' AND
meta_value != 'a:1:{s:13:"administrator";b:1;}'
来源:https://stackoverflow.com/questions/32608351/fix-wordpress-broken-database-capabilities-no-role-assigned