pre_get_blogs_of_user

Filters the list of a user's sites before it is populated.

Description

apply_filters( 'pre_get_blogs_of_user', (null) $null, (int) $user_id, (bool) $all ); 

Passing a non-null value to the filter will effectively short circuit get_blogs_of_user(), returning that value instead.

Parameters (3)

0. $null (null) => null
An array of site objects of which the user is a member.
1. $user_id (int)
The user id.
2. $all (bool)
Whether the returned array should contain all sites, including those marked deleted,, archived., or spam. Default false.

Usage

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

Defined (1)

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

/wp-includes/user.php  
  1. $sites = apply_filters( 'pre_get_blogs_of_user', null, $user_id, $all );