Outil de recherche WordPress pour les développeurs et auteurs de thèmes



add_new_user_to_blog ›

Depuis3.0.0
Dépréciéen/a
add_new_user_to_blog ( $user_id, $password, $meta )
Paramètres: (3)
  • (int) $user_id
    Requis: Oui
  • (mixed) $password Ignored.
    Requis: Oui
  • (array) $meta
    Requis: Oui
Voir:
Défini(e) dans:
Codex:
Changelog:
  • MU

Adds a newly created user to the appropriate blog

To add a user in general, use add_user_to_blog(). This function is specifically hooked into the {@see 'wpmu_activate_user'} action.



Source

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 );
		}
	}
}