Filter hook 'map_meta_cap'

in WP Core File wp-includes/capabilities.php at line 876

View Source

map_meta_cap

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

Hook Information

File Location wp-includes/capabilities.php View on GitHub
Hook Type Filter
Line Number 876

Hook Parameters

Type Name Description
string[] $caps Primitive capabilities required of the user.
string $cap Capability being checked.
int $user_id The user ID.
array $args Adds context to the capability check, typically starting with an object ID.

Usage Examples

Basic Usage
<?php
// Hook into map_meta_cap
add_filter('map_meta_cap', 'my_custom_filter', 10, 4);

function my_custom_filter($caps, $cap, $user_id, $args) {
    // Your custom filtering logic here
    return $caps;
}

Source Code Context

wp-includes/capabilities.php:876 - How this hook is used in WordPress core
<?php
 871  	 * @param string   $cap     Capability being checked.
 872  	 * @param int      $user_id The user ID.
 873  	 * @param array    $args    Adds context to the capability check, typically
 874  	 *                          starting with an object ID.
 875  	 */
 876  	return apply_filters( 'map_meta_cap', $caps, $cap, $user_id, $args );
 877  }
 878  
 879  /**
 880   * Returns whether the current user has the specified capability.
 881   *

PHP Documentation

<?php
/**
	 * Filters the primitive capabilities required of the given user to satisfy the
	 * capability being checked.
	 *
	 * @since 2.8.0
	 *
	 * @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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/capabilities.php
Related Hooks

Related hooks will be displayed here in future updates.