pre_get_blogs_of_user filter-hookWP 4.6.0

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

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

Usage

add_filter( 'pre_get_blogs_of_user', 'wp_kama_pre_get_blogs_of_user_filter', 10, 3 );

/**
 * Function for `pre_get_blogs_of_user` filter-hook.
 * 
 * @param null|object[] $sites   An array of site objects of which the user is a member.
 * @param int           $user_id User ID.
 * @param bool          $all     Whether the returned array should contain all sites, including those marked 'deleted', 'archived', or 'spam'.
 *
 * @return null|object[]
 */
function wp_kama_pre_get_blogs_of_user_filter( $sites, $user_id, $all ){

	// filter...
	return $sites;
}
$sites(null|object[])
An array of site objects of which the user is a member.
$user_id(int)
User ID.
$all(true|false)
Whether the returned array should contain all sites, including those marked 'deleted', 'archived', or 'spam'.
Default: false

Changelog

Since 4.6.0 Introduced.

Where the hook is called

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

Where the hook is used in WordPress

Usage not found.