Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php WordPress中的新用户角色_Php_Wordpress - Fatal编程技术网

Php WordPress中的新用户角色

Php WordPress中的新用户角色,php,wordpress,Php,Wordpress,我在我的functions.php文件中的WordPress中创建了新用户角色(经理)。这是我的代码,但它没有功能。经理只阅读帖子,不能编辑和删除。怎么了 Thx 根据,您添加的角色不正确。据我所知,你的特权名称与我的名字都不匹配。在我看来,最好是通过插件添加 function add_mgr_role() { add_role( 'manager', 'Manager', array( 'read' => t

我在我的functions.php文件中的WordPress中创建了新用户
角色(经理)
。这是我的代码,但它没有功能。经理只阅读帖子,不能编辑和删除。怎么了

Thx

根据,您添加的角色不正确。据我所知,你的特权名称与我的名字都不匹配。在我看来,最好是通过插件添加

function add_mgr_role()
{
    add_role(
        'manager',
        'Manager',
        array(
            'read' => true,
            'edit_posts' => true,
            'delete_posts' => true
        )
    );
}

register_activation_hook(__FILE__, 'add_mgr_role');
创建一个新的“经理”角色


很抱歉,但仍然无法使用它。用户只读取帖子。如果删除所有缓存,是否使用缓存插件。
function add_mgr_role()
{
    add_role(
        'manager',
        'Manager',
        array(
            'read' => true,
            'edit_posts' => true,
            'delete_posts' => true
        )
    );
}

register_activation_hook(__FILE__, 'add_mgr_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.';
}