get_currentuserinfo

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

WordPress Version: 4.6

/**
 * Populate global variables with information about the currently logged in user.
 *
 * @since 0.71
 * @deprecated 4.5.0 Use wp_get_current_user()
 * @see wp_get_current_user()
 *
 * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise.
 */
function get_currentuserinfo()
{
    _deprecated_function(__FUNCTION__, '4.5.0', 'wp_get_current_user()');
    return _wp_get_current_user();
}

WordPress Version: 4.5

/**
 * Populate global variables with information about the currently logged in user.
 *
 * @since 0.71
 * @deprecated 4.5.0 Use wp_get_current_user()
 * @see wp_get_current_user()
 *
 * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise.
 */
function get_currentuserinfo()
{
    _deprecated_function(__FUNCTION__, '4.5', 'wp_get_current_user()');
    return _wp_get_current_user();
}

WordPress Version: 4.3

/**
 * Populate global variables with information about the currently logged in user.
 *
 * Will set the current user, if the current user is not set. The current user
 * will be set to the logged-in person. If no user is logged-in, then it will
 * set the current user to 0, which is invalid and won't have any permissions.
 *
 * @since 0.71
 *
 * @global WP_User $current_user Checks if the current user is set
 *
 * @return false|void False on XML-RPC Request and invalid auth cookie.
 */
function get_currentuserinfo()
{
    global $current_user;
    if (!empty($current_user)) {
        if ($current_user instanceof WP_User) {
            return;
        }
        // Upgrade stdClass to WP_User
        if (is_object($current_user) && isset($current_user->ID)) {
            $cur_id = $current_user->ID;
            $current_user = null;
            wp_set_current_user($cur_id);
            return;
        }
        // $current_user has a junk value. Force to WP_User with ID 0.
        $current_user = null;
        wp_set_current_user(0);
        return false;
    }
    if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
        wp_set_current_user(0);
        return false;
    }
    /**
     * Filter the current user.
     *
     * The default filters use this to determine the current user from the
     * request's cookies, if available.
     *
     * Returning a value of false will effectively short-circuit setting
     * the current user.
     *
     * @since 3.9.0
     *
     * @param int|bool $user_id User ID if one has been determined, false otherwise.
     */
    $user_id = apply_filters('determine_current_user', false);
    if (!$user_id) {
        wp_set_current_user(0);
        return false;
    }
    wp_set_current_user($user_id);
}

WordPress Version: 4.1

/**
 * Populate global variables with information about the currently logged in user.
 *
 * Will set the current user, if the current user is not set. The current user
 * will be set to the logged-in person. If no user is logged-in, then it will
 * set the current user to 0, which is invalid and won't have any permissions.
 *
 * @since 0.71
 *
 * @uses $current_user Checks if the current user is set
 *
 * @return null|false False on XML-RPC Request and invalid auth cookie. Null when current user set.
 */
function get_currentuserinfo()
{
    global $current_user;
    if (!empty($current_user)) {
        if ($current_user instanceof WP_User) {
            return;
        }
        // Upgrade stdClass to WP_User
        if (is_object($current_user) && isset($current_user->ID)) {
            $cur_id = $current_user->ID;
            $current_user = null;
            wp_set_current_user($cur_id);
            return;
        }
        // $current_user has a junk value. Force to WP_User with ID 0.
        $current_user = null;
        wp_set_current_user(0);
        return false;
    }
    if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
        wp_set_current_user(0);
        return false;
    }
    /**
     * Filter the current user.
     *
     * The default filters use this to determine the current user from the
     * request's cookies, if available.
     *
     * Returning a value of false will effectively short-circuit setting
     * the current user.
     *
     * @since 3.9.0
     *
     * @param int|bool $user_id User ID if one has been determined, false otherwise.
     */
    $user_id = apply_filters('determine_current_user', false);
    if (!$user_id) {
        wp_set_current_user(0);
        return false;
    }
    wp_set_current_user($user_id);
}

WordPress Version: 3.9

/**
 * Populate global variables with information about the currently logged in user.
 *
 * Will set the current user, if the current user is not set. The current user
 * will be set to the logged-in person. If no user is logged-in, then it will
 * set the current user to 0, which is invalid and won't have any permissions.
 *
 * @since 0.71
 *
 * @uses $current_user Checks if the current user is set
 * @uses wp_validate_auth_cookie() Retrieves current logged in user.
 *
 * @return bool|null False on XML-RPC Request and invalid auth cookie. Null when current user set.
 */
function get_currentuserinfo()
{
    global $current_user;
    if (!empty($current_user)) {
        if ($current_user instanceof WP_User) {
            return;
        }
        // Upgrade stdClass to WP_User
        if (is_object($current_user) && isset($current_user->ID)) {
            $cur_id = $current_user->ID;
            $current_user = null;
            wp_set_current_user($cur_id);
            return;
        }
        // $current_user has a junk value. Force to WP_User with ID 0.
        $current_user = null;
        wp_set_current_user(0);
        return false;
    }
    if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
        wp_set_current_user(0);
        return false;
    }
    /**
     * Filter the current user.
     *
     * The default filters use this to determine the current user from the
     * request's cookies, if available.
     *
     * Returning a value of false will effectively short-circuit setting
     * the current user.
     *
     * @since 3.9.0
     *
     * @param int|bool $user_id User ID if one has been determined, false otherwise.
     */
    $user_id = apply_filters('determine_current_user', false);
    if (!$user_id) {
        wp_set_current_user(0);
        return false;
    }
    wp_set_current_user($user_id);
}

WordPress Version: 3.7

/**
 * Populate global variables with information about the currently logged in user.
 *
 * Will set the current user, if the current user is not set. The current user
 * will be set to the logged in person. If no user is logged in, then it will
 * set the current user to 0, which is invalid and won't have any permissions.
 *
 * @since 0.71
 * @uses $current_user Checks if the current user is set
 * @uses wp_validate_auth_cookie() Retrieves current logged in user.
 *
 * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
 */
function get_currentuserinfo()
{
    global $current_user;
    if (!empty($current_user)) {
        if ($current_user instanceof WP_User) {
            return;
        }
        // Upgrade stdClass to WP_User
        if (is_object($current_user) && isset($current_user->ID)) {
            $cur_id = $current_user->ID;
            $current_user = null;
            wp_set_current_user($cur_id);
            return;
        }
        // $current_user has a junk value. Force to WP_User with ID 0.
        $current_user = null;
        wp_set_current_user(0);
        return false;
    }
    if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
        wp_set_current_user(0);
        return false;
    }
    if (!$user = wp_validate_auth_cookie()) {
        if (is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in')) {
            wp_set_current_user(0);
            return false;
        }
    }
    wp_set_current_user($user);
}