wphooks.info - can_add_user_to_blog

can_add_user_to_blog

(trunk - 5.0-alpha-42177)

*** New in trunk ***

The hook occurs in the following file:

wp-includes/ms-functions.php:
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
	 * Filters whether a user should be added to a site.
	 *
	 * @since 4.9.0
	 *
	 * @param bool|WP_Error $retval  True if the user should be added to the site, false
	 *                               or error object otherwise.
	 * @param int           $user_id User ID.
	 * @param string        $role    User role.
	 * @param int           $blog_id Site ID.
	 */
	$can_add_user = apply_filters( 'can_add_user_to_blog', true, $user_id, $role, $blog_id );

	if ( true !== $can_add_user ) {
		restore_current_blog();

		if ( is_wp_error( $can_add_user ) ) {
			return $can_add_user;
		}

		return new WP_Error( 'user_cannot_be_added', __( 'User cannot be added to this site.' ) );