修复 Wordpress 损坏的数据库:功能/未分配角色 [英] Fix Wordpress broken database : capabilities / no role assigned
问题描述
我正在一个有这个错误的 Wordpress 网站上工作:9000 个用户应该是订阅者"(Wordpress 角色),但他们现在没有分配角色(可能是由于用户导入脚本):
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) :
图片:http://i.imgur.com/GulqggZ.jpg
在meta_value中,我们可以看到他们的名字而不是角色:Dupont, Maurice ...如何将角色/能力订阅者"分配给所有没有角色的用户?
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 ?
我发现了一个批量执行此操作的插件,但它无法处理超过 1000-2000 个用户,并且下载链接已损坏.
I found a plugin doing this in bulk but it cannot handle more than 1000-2000 users and the link for download is broken.
非常感谢
推荐答案
您可以通过一个查询来完成此操作.请在运行之前检查 a:1:{s:13:"administrator";b: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;}'
这篇关于修复 Wordpress 损坏的数据库:功能/未分配角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!