Solution:
By WP_Role we can easily update the role by removing or adding new capabilities. Bellow a sample example for user role Administrator.
WP_Roles => array(
'roles' => array(
'administrator' => array(
'name' => 'administrator',
'capabilities' => array(
'switch_themes' => true,
'edit_themes' => true,
'activate_plugins' => true,
// Much more
),
// Other roles
),
'role_names' => array(
'administrator' => 'Administrator',
// Other role names
)
// ...
);
You can get full understanding to go through official documents.
Here is the link of official documents of WordPress Role and Permission. https://developer.wordpress.org/plugins/users/roles-and-capabilities/