gpt4 book ai didi

php - WordPress 中的新用户角色

转载 作者:行者123 更新时间:2023-12-04 14:48:57 25 4
gpt4 key购买 nike

我在 WordPress 的functions.php 文件中创建了新用户角色(经理)。这是我的代码,但它不起作用。管理员只能查看帖子,不能编辑和删除。怎么了?

谢谢。

function ui_new_role() {  

//add the new user role
add_role(
'manager',
'Manager',
array(

'edit_' => true,
'read_' => true,
'delete_' => true,


'edit_s' => true,
'edit_others_s' => true,
'publish_s' => true,
'read_private_s' => true,


'delete_s' => true,
'delete_private_s' => true,
'delete_published_s' => true,
'delete_others_s' => true,
'edit_private_s' => true,
'edit_published_s' => true,
)
);

}
add_action('admin_init', 'ui_new_role');

最佳答案

创建一个新的“经理”角色。

$result = add_role(
'manager',
__( 'Manager' ),
array(
'read' => true, // true allows this capability
'edit_posts' => true,
'delete_posts' => true, // Use false to explicitly deny
)
);
if ( null !== $result ) {
echo 'New role created!';
}
else {
echo 'Manager role already exists.';
}

reference

关于php - WordPress 中的新用户角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53209891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com