Fix Wordpress broken database : capabilities / no

2019-09-09 00:28发布

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条回答
别忘想泡老子
2楼-- · 2019-09-09 00:34

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;}'
查看更多
登录 后发表回答