map_meta_cap
map_meta_cap ( $cap, $user_id, $args )
Parameters:- (string) cap Capability being checked.
- (int) user_id User ID.
- (mixed) args Optional further parameters, typically starting with an object ID.
Returns:- (string[]) Primitive capabilities required of the user.
Defined at:Change Log: - Introduced in WordPress: 2.0.0
- Deprecated in WordPress: —
Description
Maps a capability to the primitive capabilities required of the given user to
satisfy the capability being checked.This function also accepts an ID of an object to map against if the capability is a meta capability. Meta
capabilities such as `edit_post` and `edit_user` are capabilities used by this function to map to primitive
capabilities that a user or role requires, such as `edit_posts` and `edit_others_posts`.
Example usage:
map_meta_cap( 'edit_posts', $user->ID );
map_meta_cap( 'edit_post', $user->ID, $post->ID );
map_meta_cap( 'edit_post_meta', $user->ID, $post->ID, $meta_key );
This function does not check whether the user has the required capabilities,
it just returns what the required capabilities are.