add_existing_user_to_blog

Add a user to a blog based on details from maybe_add_existing_user_to_blog().

Description

(true|WP_Error|void) add_existing_user_to_blog( (bool) $details = false ); 

Returns (true|WP_Error|void)

Parameters (1)

0. $details — Optional. (bool) => false
The details.

Usage

  1. if ( !function_exists( 'add_existing_user_to_blog' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4. // The details. 
  5. $details = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = add_existing_user_to_blog($details); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-functions.php  
  1. function add_existing_user_to_blog( $details = false ) { 
  2. if ( is_array( $details ) ) { 
  3. $blog_id = get_current_blog_id(); 
  4. $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] ); 
  5. /** 
  6. * Fires immediately after an existing user is added to a site. 
  7. * @since MU 
  8. * @param int $user_id User ID. 
  9. * @param mixed $result True on success or a WP_Error object if the user doesn't exist. 
  10. */ 
  11. do_action( 'added_existing_user', $details['user_id'], $result ); 
  12. return $result;