add_existing_user_to_blog

The timeline below displays how wordpress function add_existing_user_to_blog has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Adds a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU (3.0.0)
 *
 * @param array|false $details {
 *     User details. Must at least contain values for the keys listed below.
 *
 *     @type int    $user_id The ID of the user being added to the current blog.
 *     @type string $role    The role to be assigned to the user.
 * }
 * @return true|WP_Error|void True on success or a WP_Error object if the user doesn't exist
 *                            or could not be added. Void if $details array was not provided.
 */
function add_existing_user_to_blog($details = false)
{
    if (is_array($details)) {
        $blog_id = get_current_blog_id();
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU (3.0.0)
         *
         * @param int           $user_id User ID.
         * @param true|WP_Error $result  True on success or a WP_Error object if the user doesn't exist
         *                               or could not be added.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 5.7

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU (3.0.0)
 *
 * @param array|false $details {
 *     User details. Must at least contain values for the keys listed below.
 *
 *     @type int    $user_id The ID of the user being added to the current blog.
 *     @type string $role    The role to be assigned to the user.
 * }
 * @return true|WP_Error|void True on success or a WP_Error object if the user doesn't exist
 *                            or could not be added. Void if $details array was not provided.
 */
function add_existing_user_to_blog($details = false)
{
    if (is_array($details)) {
        $blog_id = get_current_blog_id();
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU (3.0.0)
         *
         * @param int           $user_id User ID.
         * @param true|WP_Error $result  True on success or a WP_Error object if the user doesn't exist
         *                               or could not be added.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 5.5

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU (3.0.0)
 *
 * @param array $details {
 *     User details. Must at least contain values for the keys listed below.
 *
 *     @type int    $user_id The ID of the user being added to the current blog.
 *     @type string $role    The role to be assigned to the user.
 * }
 * @return true|WP_Error|void True on success or a WP_Error object if the user doesn't exist
 *                            or could not be added. Void if $details array was not provided.
 */
function add_existing_user_to_blog($details = false)
{
    if (is_array($details)) {
        $blog_id = get_current_blog_id();
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU (3.0.0)
         *
         * @param int           $user_id User ID.
         * @param true|WP_Error $result  True on success or a WP_Error object if the user doesn't exist
         *                               or could not be added.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 5.4

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU (3.0.0)
 *
 * @param array $details User details.
 * @return true|WP_Error|void True on success or a WP_Error object if the user doesn't exist
 *                            or could not be added. Void if $details array was not provided.
 */
function add_existing_user_to_blog($details = false)
{
    if (is_array($details)) {
        $blog_id = get_current_blog_id();
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU (3.0.0)
         *
         * @param int           $user_id User ID.
         * @param true|WP_Error $result  True on success or a WP_Error object if the user doesn't exist
         *                               or could not be added.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 4.9

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU (3.0.0)
 *
 * @param array $details
 * @return true|WP_Error|void
 */
function add_existing_user_to_blog($details = false)
{
    if (is_array($details)) {
        $blog_id = get_current_blog_id();
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU (3.0.0)
         *
         * @param int   $user_id User ID.
         * @param mixed $result  True on success or a WP_Error object if the user doesn't exist
         *                       or could not be added.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 4.7

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU
 *
 * @param array $details
 * @return true|WP_Error|void
 */
function add_existing_user_to_blog($details = false)
{
    if (is_array($details)) {
        $blog_id = get_current_blog_id();
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU
         *
         * @param int   $user_id User ID.
         * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 4.3

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU
 *
 * @global int $blog_id
 *
 * @param array $details
 * @return true|WP_Error|void
 */
function add_existing_user_to_blog($details = false)
{
    global $blog_id;
    if (is_array($details)) {
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU
         *
         * @param int   $user_id User ID.
         * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
         */
        do_action('added_existing_user', $details['user_id'], $result);
        return $result;
    }
}

WordPress Version: 4.1

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU
 *
 * @param array $details
 */
function add_existing_user_to_blog($details = false)
{
    global $blog_id;
    if (is_array($details)) {
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU
         *
         * @param int   $user_id User ID.
         * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
         */
        do_action('added_existing_user', $details['user_id'], $result);
    }
    return $result;
}

WordPress Version: 3.8

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU
 * @uses add_user_to_blog()
 *
 * @param array $details
 */
function add_existing_user_to_blog($details = false)
{
    global $blog_id;
    if (is_array($details)) {
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        /**
         * Fires immediately after an existing user is added to a site.
         *
         * @since MU
         *
         * @param int   $user_id User ID.
         * @param mixed $result  True on success or a WP_Error object if the user doesn't exist.
         */
        do_action('added_existing_user', $details['user_id'], $result);
    }
    return $result;
}

WordPress Version: 3.7

/**
 * Add a user to a blog based on details from maybe_add_existing_user_to_blog().
 *
 * @since MU
 * @uses add_user_to_blog()
 *
 * @param array $details
 */
function add_existing_user_to_blog($details = false)
{
    global $blog_id;
    if (is_array($details)) {
        $result = add_user_to_blog($blog_id, $details['user_id'], $details['role']);
        do_action('added_existing_user', $details['user_id'], $result);
    }
    return $result;
}