I have created new role in wordpress, I want that user with this role can login into wordpress admin.
$result = add_role( 'sub_admin', __(
'Sub Admin' ),
array(
'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'create_posts' => true, // Allows user to create new posts
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
'install_plugins' => false, // User cant add new plugins
'update_plugin' => false, // User canât update any plugins
'update_core' => false // user cant perform core updates
)
);
This is the code i added to add new role..Can any one suggest me the solution?
read
allows access to administration panel. You already have it. You can find more about capabilities and which roles they’re assigned to by default hereWhile creating new role, make sure that appropriate capabilities are assigned to that role. For example, following code will add three permissions
"read"
Allows access to Administration Panel options:
i.e. Dashboard and Users > Your Profile
"edit_posts"
Allows to edit posts
"delete_posts"
Allows to delete posts
So user added to this role will have all these capabilities inherited from this role.
You can try this plugin https://wordpress.org/plugins/capability-manager-enhanced/screenshots/
It will provide you all the functionalities like
Moreover, You can view the capabilities of admin and author user role to understand which capabilities will be required to allow user to access specific area.
That’s all
WordPress is all about plugins. So, it would be easy if you find any plugin for your requirements. It will save your all the time and it will do all the coding for you.