I added a user role to access to backend. Even after I added more than 70 capabilities, Wp-admin page is showing "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",
)
);
But this is not working.
How can I fix to to access dashboard?
Seems you are adding role but not actually passing what capabilities needs to be true, Correct syntax is :
add_role(
'custom_role', 'Custom Role Name',
array(
'read' => true,
'level_0' => true
)
);