Fix Wordpress broken database : capabilities / no role assigned

隐身守侯 提交于 2019-12-11 17:59:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!