role_has_cap

Filters which capabilities a role has.

Description

apply_filters( 'role_has_cap', (array) $this_capabilities, (string) $cap, (string) $this_name ); 

Parameters (3)

0. $this_capabilities (array)
Array of role capabilities.
1. $cap (string)
Capability name.
2. $this_name (string)
The this name.

Usage

To run the hook, copy the example below.
  1. $this_capabilities = apply_filters( 'role_has_cap', $this_capabilities, $cap, $this_name ); 
  2.  
  3. if ( !empty( $this_capabilities ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the role_has_cap callback 
  2. function filter_role_has_cap( $this_capabilities, $cap, $this_name ) { 
  3. // make filter magic happen here... 
  4. return $this_capabilities
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'role_has_cap', 'filter_role_has_cap', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'role_has_cap', 'filter_role_has_cap', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/class-wp-role.php  
  1. $capabilities = apply_filters( 'role_has_cap', $this->capabilities, $cap, $this->name );