访问后端的 Wordpress 用户角色不起作用
Wordpress User Role to access backend is not working
我添加了一个用户角色来访问后端。即使在我添加了 70 多个功能之后,Wp-admin 页面仍显示 "Sorry, you are not allowed to access this page."
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",
)
);
但这不起作用。
如何修复以访问仪表板?
似乎您正在添加角色,但实际上并没有传递需要的功能,正确的语法是:
add_role(
'custom_role', 'Custom Role Name',
array(
'read' => true,
'level_0' => true
)
);
我添加了一个用户角色来访问后端。即使在我添加了 70 多个功能之后,Wp-admin 页面仍显示 "Sorry, you are not allowed to access this page."
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",
)
);
但这不起作用。
如何修复以访问仪表板?
似乎您正在添加角色,但实际上并没有传递需要的功能,正确的语法是:
add_role(
'custom_role', 'Custom Role Name',
array(
'read' => true,
'level_0' => true
)
);