can_add_user_to_blog filter-hookWP 4.9.0

Filters whether a user should be added to a site.

Usage

add_filter( 'can_add_user_to_blog', 'wp_kama_can_add_user_to_blog_filter', 10, 4 );

/**
 * Function for `can_add_user_to_blog` filter-hook.
 * 
 * @param true|WP_Error $retval  True if the user should be added to the site, error object otherwise.
 * @param int           $user_id User ID.
 * @param string        $role    User role.
 * @param int           $blog_id Site ID.
 *
 * @return true|WP_Error
 */
function wp_kama_can_add_user_to_blog_filter( $retval, $user_id, $role, $blog_id ){

	// filter...
	return $retval;
}
$retval(true|WP_Error)
True if the user should be added to the site, error object otherwise.
$user_id(int)
User ID.
$role(string)
User role.
$blog_id(int)
Site ID.

Changelog

Since 4.9.0 Introduced.

Where the hook is called

add_user_to_blog()
can_add_user_to_blog
wp-includes/ms-functions.php 173
$can_add_user = apply_filters( 'can_add_user_to_blog', true, $user_id, $role, $blog_id );

Where the hook is used in WordPress

Usage not found.