setup_userdata example

// If `$id` matches the current user, there is nothing to do.         if ( isset( $current_user )
        && ( $current_user instanceof WP_User )
        && ( $id == $current_user->ID )
        && ( null !== $id )
        ) {
            return $current_user;
        }

        $current_user = new WP_User( $id$name );

        setup_userdata( $current_user->ID );

        /** * Fires after the current user is set. * * @since 2.0.1 */
        do_action( 'set_current_user' );

        return $current_user;
    }
endif;

Home | Imprint | This part of the site doesn't use cookies.