add_new_user_to_blog

Definition:
function add_new_user_to_blog( $user_id, $email, $meta ) {}

Add a newly created user to the appropriate blog

Parameters

  • int $user_id
  • string $email
  • array $meta

Source code

function add_new_user_to_blog( $user_id, $email, $meta ) {

	global $current_site;

	if ( !empty( $meta[ 'add_to_blog' ] ) ) {

		$blog_id = $meta[ 'add_to_blog' ];

		$role = $meta[ 'new_role' ];

		remove_user_from_blog($user_id, $current_site->blog_id); // remove user from main blog.

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

		update_user_meta( $user_id, 'primary_blog', $blog_id );

	}

}

261

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: