我在我的functions.php文件中的WordPress中创建了新用户role (Manager)。这是我的代码,但是不起作用。管理员仅阅读帖子,无法编辑和删除。怎么了?

谢谢。

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/

10-12 16:45