I have created 'news' custom post-type with CPTUI. And add 'news_manager' user role with these capabilities
edit_post
edit_posts
publish_posts
edit_others_posts
edit_published_posts
Then basically blocking access to some page with remove_menu_page by admin_menu action
remove_menu_page( 'index.php' );
remove_menu_page( 'edit.php?post_type=blog' );
Then making the role redirect to 'edit.php?post_type=news'
function loginRedirect( $redirect_to, $request, $user ){
if ( current_user_can( 'news_manager' ) ) {
return "/wp-admin/edit.php?post_type=news";
}
return $redirect_to;
}
add_filter("login_redirect", "loginRedirect", 50, 3);
But when I created a news_manager user and login with that. URL redirect is correct. But getting blocked, wordpress saying these
You do not have sufficient permissions to access this admin page.
Reason: The current user has the "edit_posts" capability that is required to access the "News → All News" menu item.
These only blocked on edit.php page. If access specific post it's pass. '/wp-admin/post.php?post=22&action=edit' for example
It's said the user have capability to view but blocking access. Why? and How to fix these.
Versions
- Wordpress 4.9.4
- Custom Post Type UI 1.5.6