Shold I manually add ‘cap’ to admin role ?

A new capability has to be explicitly added to either a role or a user. In your case if you want all administrators to have ‘cap’ capability you will add it to ‘administrator’ role:

$role = get_role( 'administrator' );
$role->add_cap( 'cap' );

If you want a specific administrator only to have ‘cap’ capability then you add it to this particular user:

$user = new WP_User( $user_id ); // $user_id = id of your administrator user
$user->add_cap( 'cap' );

Leave a Comment