bp_user_can

Filters whether or not the specified user has a given capability on a given site.

Description

apply_filters( 'bp_user_can', (bool) $retval, (int) $user_id, (string) $capability, (int) $site_id, (array) $args ); 

Parameters (5)

0. $retval (bool)
Whether or not the current user has the capability.
1. $user_id (int)
The user id.
2. $capability (string)
The capability being checked for.
3. $site_id (int)
Site ID. Defaults to the BP root blog.
4. $args (array)
Array of extra arguments passed.

Usage

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

Defined (1)

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

/bp-core/bp-core-caps.php  
  1. $retval = (bool) apply_filters( 'bp_user_can', $retval, $user_id, $capability, $site_id, $args );