map_meta_cap filter-hookWP 2.8.0

Filters the primitive capabilities required of the given user to satisfy the capability being checked.

Usage

add_filter( 'map_meta_cap', 'wp_kama_map_meta_cap_filter', 10, 4 );

/**
 * Function for `map_meta_cap` filter-hook.
 * 
 * @param string[] $caps    Primitive capabilities required of the user.
 * @param string   $cap     Capability being checked.
 * @param int      $user_id The user ID.
 * @param array    $args    Adds context to the capability check, typically starting with an object ID.
 *
 * @return string[]
 */
function wp_kama_map_meta_cap_filter( $caps, $cap, $user_id, $args ){

	// filter...
	return $caps;
}
$caps(string[])
Primitive capabilities required of the user.
$cap(string)
Capability being checked.
$user_id(int)
The user ID.
$args(array)
Adds context to the capability check, typically starting with an object ID.

Changelog

Since 2.8.0 Introduced.

Where the hook is called

map_meta_cap()
map_meta_cap
wp-includes/capabilities.php 842
return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args );

Where the hook is used in WordPress

wp-includes/class-wp-customize-manager.php 2958
add_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10, 4 );
wp-includes/class-wp-customize-manager.php 2965
remove_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10 );