最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

users - What's the difference between the capability remove_users and delete_users?

programmeradmin3浏览0评论

In the list of capabilities, I found there's both remove_users and delete_users. It's not clear to me what remove_users is supposed to do, the Codex documentation just says it was introduced in version 3.0 (/).

In the list of capabilities, I found there's both remove_users and delete_users. It's not clear to me what remove_users is supposed to do, the Codex documentation just says it was introduced in version 3.0 (https://wordpress.org/support/article/roles-and-capabilities/).

Share Improve this question edited Mar 1, 2022 at 21:38 Klemart3D 1134 bronze badges asked Apr 19, 2019 at 23:24 reedreed 2251 silver badge6 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 13

The difference is really no difference in regular (single install) WordPress. It's in a multisite install (network) where there is a difference.

In multisite, only a Super Admin (who can manage everything on the network) has delete_users capability, while an "admin" (who would own/manage a single site) can remove_users from their site, but cannot delete them from the network.

Hope that helps clarify.

remove_users is no more used.

Source: https://wpfront.com/wordpress-plugins/user-role-editor-plugin/wordpress-capabilities/#remove_users

Use delete_users instead both in a multisite install (network) or a single install.

We also can read some mistakes on the web like here:

Even with the delete_users permission you can not delete users with more permissions that you.

That's wrong, an editor user with delete_users (and list_users) capability can delete an administrator with following code:

function add_editor_delete_users_cap() {
    if ( $role = get_role( 'editor' ) ) {
        if( !$role->has_cap( 'list_users' ) ) $role->add_cap( 'list_users' );
        if( !$role->has_cap( 'delete_users' ) ) $role->add_cap( 'delete_users' );
    }
}
add_action( 'admin_init', 'add_editor_delete_users_cap' );
发布评论

评论列表(0)

  1. 暂无评论