0

我添加了一个用户角色来访问后端。即使我添加了 70 多个功能,Wp-admin 页面仍然显示“对不起,您无权访问此页面”。

add_role( 'employer', 'Employer', 
    array(
"switch_themes",
"edit_themes",
"activate_plugins",
"edit_plugins",
"edit_users",
"edit_files",
"manage_options",
"moderate_comments",
"manage_categories",
"manage_links",
"upload_files",
"import",
"unfiltered_html",
"edit_posts",
 "edit_others_posts",
"edit_published_posts",
"publish_posts",
"edit_pages",
"read",
"level_10",
...
 "manage_job_listing_terms",
"edit_job_listing_terms",
"delete_job_listing_terms",
 "assign_job_listing_terms",
"administrator",
    )
);

但这不起作用。

如何修复以访问仪表板?

4

1 回答 1

2

似乎您正在添加角色但实际上并未传递真正需要的功能,正确的语法是:

add_role( 
    'custom_role', 'Custom Role Name',
        array(
            'read' => true,
            'level_0' => true
        )
);

查看文档:Wordpress 角色

于 2020-02-10T09:21:08.437 回答