pre_get_blogs_of_user хук-фильтрWP 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.

Использование

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'.
По умолчанию: false

Список изменений

С версии 4.6.0 Введена.

Где вызывается хук

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

Где используется хук в WordPress

Использование не найдено.