There are 6 types of user role defined in Wordpress by default. These user type/roles make insure that the user can only use only few WordPress website features only. It minimize the chances of any accidents happening that could potentially bring down the site. in
In most of the cases , the WordPress default user roles are enough to meet the requirements but sometimes there is a need of a custom WordPress users that can have access only to limited things.We can have this feature by using some of the plugins but we recommend of using the code because of some securities.
For making a custom role , we only have to use a small function in Wordpress.
We are only going to use the add_role() function .
So we are giving the user role a name ‘Client’.
In this we will give this user functionality to-->
Edit Others posts
We are going to put this small code into the functions.php file for our current theme.
after adding this code , we will see that the user type has been created in the backend. But now we have to give this user access to the limited things in wordpress.
Just add the array code to what you have already entered into your functions.php file.
// Add a custom user role
$result = add_role( 'client', __(
'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => true, // Allows user to edit others posts not just their own
'create_posts' => true, // Allows user to create new posts
'manage_categories' => true, // Allows user to manage post categories
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
After adding this code when you will create a user with role of 'client' , that user will only see access to that field only in which we have given permission in function.php file