get_blogs_of_user

Filters the list of sites a user belongs to.

Description

apply_filters( 'get_blogs_of_user', (array) $sites, (int) $user_id, (bool) $all ); 

Parameters (3)

0. $sites (array)
An array of site objects belonging to the user.
1. $user_id (int)
The user id.
2. $all (bool)
Whether the returned sites array should contain all sites, including those marked deleted,, archived., or spam. Default false.

Usage

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

Defined (1)

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

/wp-includes/user.php  
  1. return apply_filters( 'get_blogs_of_user', $sites, $user_id, $all );