回答:
wp_set_auth_cookie() パスワードを知らなくてもユーザーをログインさせます。
is_user_logged_in()が機能しないようです。Cookieとは異なるものを見ているかどうか知っていますか?
                    wp_set_current_userログインする前に試してください
                    wp_set_auth_cookie()サインイン機能に追加しました。私はそれを再考する必要があると思います。また、wp_set_current_userを検索して報告します。これにご協力いただきありがとうございます!
                    次のコードは、パスワードなしで自動ログインを実行します!
// Automatic login //
$username = "Admin";
$user = get_user_by('login', $username );
// Redirect URL //
if ( !is_wp_error( $user ) )
{
    wp_clear_auth_cookie();
    wp_set_current_user ( $user->ID );
    wp_set_auth_cookie  ( $user->ID );
    $redirect_to = user_admin_url();
    wp_safe_redirect( $redirect_to );
    exit();
}get_user_by()失敗するとfalseを返すため、WP_Errorオブジェクトの代わりにfalseをチェックする必要があります
                    ここで、より良いアプローチを使用する別のソリューションを見つけました(少なくとも私の意見では...)。Cookieを設定する必要はありません。WordpressAPIを使用します。
/**
 * Programmatically logs a user in
 * 
 * @param string $username
 * @return bool True if the login was successful; false if it wasn't
 */
    function programmatic_login( $username ) {
        if ( is_user_logged_in() ) {
            wp_logout();
        }
    add_filter( 'authenticate', 'allow_programmatic_login', 10, 3 );    // hook in earlier than other callbacks to short-circuit them
    $user = wp_signon( array( 'user_login' => $username ) );
    remove_filter( 'authenticate', 'allow_programmatic_login', 10, 3 );
    if ( is_a( $user, 'WP_User' ) ) {
        wp_set_current_user( $user->ID, $user->user_login );
        if ( is_user_logged_in() ) {
            return true;
        }
    }
    return false;
 }
 /**
  * An 'authenticate' filter callback that authenticates the user using only     the username.
  *
  * To avoid potential security vulnerabilities, this should only be used in     the context of a programmatic login,
  * and unhooked immediately after it fires.
  * 
  * @param WP_User $user
  * @param string $username
  * @param string $password
  * @return bool|WP_User a WP_User object if the username matched an existing user, or false if it didn't
  */
 function allow_programmatic_login( $user, $username, $password ) {
    return get_user_by( 'login', $username );
 }コードは自明だと思います:
フィルターは、指定されたユーザー名のWP_Userオブジェクトを検索して返します。wp_set_current_userによって返されたWP_Userオブジェクトを使用した関数の呼び出し、関数をwp_signon使用したis_user_logged_inログインの確認、およびそれだけです!
私の意見では、きれいできれいなコードです!
$credentialsが空かどうかをチェックします。配列が空でない場合(これは私の答えです)、配列の値はユーザーの認証に使用されます。
                    マイク、ポール、シェードに加えて:
login.phpリダイレクトを適切に処理するには:
//---------------------Automatic login--------------------
if(!is_user_logged_in()){
    $username = "user1";
    if($user=get_user_by('login',$username)){
        clean_user_cache($user->ID);
        wp_clear_auth_cookie();
        wp_set_current_user( $user->ID );
        wp_set_auth_cookie( $user->ID , true, false);
        update_user_caches($user);
        if(is_user_logged_in()){
            $redirect_to = user_admin_url();
            wp_safe_redirect( $redirect_to );
            exit;
        }
    }
}
elseif('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] == wp_login_url()){
    $redirect_to = user_admin_url();
    wp_safe_redirect( $redirect_to );
    exit;
}wp-config.php直後に配置する
require_once(ABSPATH . 'wp-settings.php');参考までに
上記のソリューションに基づいて、ユーザーデータとCookieセッションを同期することにより、ユーザーが1つのワードプレスから別のワードプレスにログインし続けるためのプラグインをリリースしました。