在 WordPress 中修改指定角色的权限,需要借助 WP_Role 操作。
下面的代码,为 simple_role 添加 edit_others_posts 权限。
function wporg_simple_role_caps() {
// Gets the simple_role role object.
$role = get_role( 'simple_role' );
// Add a new capability.
$role->add_cap( 'edit_others_posts', true );
}
// Add simple_role capabilities, priority must be after the initial role definition.
add_action( 'init', 'wporg_simple_role_caps', 11 );
WP_Role 的几个重要方法:
add_cap -- 为角色分配功能。
has_cap -- 确定角色是否具有给定的功能。
remove_cap -- 从角色中删除功能。
-
WordPress公司官网主题在众多的WordPress企业官网主题中,追格公司推出了多款关于WordPress企业官网主题作品。我们之前已经分享过一些关于追格的企业官网主题,包括收费和免费版本,这些主题都因其独特的设计和出色的功能而深受用户喜爱。
-
Fluent Forms - WordPress表单插件Fluent Forms是一款功能强大且易于使用的WordPress表单插件,适合各种规模的网站使用。无论是简单的联系表单还是复杂的用户调查表,Fluent Forms都能满足用户的需求。
-
WP-Ban WordPress禁止指定IP访问网站的插件WP-Ban是一款专为WordPress网站设计的安全插件,其主要功能是屏蔽恶意或不受欢迎的IP地址,以增强网站的安全性。
-
WPvivid插件:WordPress网站备份与还原的解决方案WPvivid插件是一款功能强大的WordPress插件,专为网站数据备份、还原和搬家设计。它支持高度自定义的备份选项,允许用户选择备份整个站点(包括数据库和文件)、仅文件或仅数据库。
-
Dashboard Notes WordPress仪表盘中添加备注信息的实用插件WP Dashboard Notes插件是WordPress平台上一个实用的仪表盘备注信息工具,它可以帮助网站管理者更好地记录和管理网站的日常维护工作、待办事项等。通过该插件的自定义备注和待办列表功能,用户可以更好的跟踪和完成任务,提高网站管理的效率和质量。
-
FluentSMTP一款功能强大且免费的WordPress SMTP插件FluentSMTP是一款功能强大且免费的SMTP插件,它支持为WordPress配置多个SMTP发送服务器。
暂无评论,抢个沙发...