I’ve just created a custom user role of ‘Lister’ by using the code below in my functions.php file.
I have the new role working in the backend and have created a user for testing. Once logged in, the only menu options is Profile and Dashboard. Why aren’t the Posts menu item there?
Thanks
$lister_user_role = add_role('lister', __('Lister'),
array(
'read' => true, //true allows this capability
'edit_posts' => true, //allows user to edit posts
'create_posts' => true, //allows users to create posts
'publish_posts' => true, //allows users to publish posts
'delete_posts' => false, //do not allow user to delete posts
'edit_others_posts' => false, //do not allow a lister to edit others' posts
'edit_themes' => false, //do not allow a lister to edit theme
'install_plugins' => false, //do not allow a lister to install plugins
'update_plugin' => false, //do not allow a lister to update plugins
'update_core' => false //do not allow a lister to update WP Core
)
);
From add_role article in codex (https://codex.wordpress.org/Function_Reference/add_role):
In other words, when you created your role for the first time & executed your site, the role was created. In that time probably you did not set all the fields you want. So, to update your new user role, you should first delete it with remove_role (https://codex.wordpress.org/Function_Reference/remove_role) & then add_role again.
Also, after recreation of the role, try to assign the user to any other role & then back to your “lister” role again. Hope that will help.