add_new_user_to_blog( int $user_id, mixed $password, array $meta )

Adds a newly created user to the appropriate blog


Description Description

To add a user in general, use add_user_to_blog(). This function is specifically hooked into the ‘wpmu_activate_user’ action.

See also See also


Top ↑

Parameters Parameters

$user_id

(int) (Required)

$password

(mixed) (Required) Ignored.

$meta

(array) (Required)


Top ↑

Source Source

File: wp-includes/ms-functions.php

function add_new_user_to_blog( $user_id, $password, $meta ) {
	if ( ! empty( $meta['add_to_blog'] ) ) {
		$blog_id = $meta['add_to_blog'];
		$role    = $meta['new_role'];
		remove_user_from_blog( $user_id, get_network()->site_id ); // remove user from main blog.

		$result = add_user_to_blog( $blog_id, $user_id, $role );

		if ( ! is_wp_error( $result ) ) {
			update_user_meta( $user_id, 'primary_blog', $blog_id );
		}
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
MU (3.0.0) Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.