Viewing 6 replies - 1 through 6 (of 6 total)
  • That’s because you might have installed WordPress in a subdirectory? Try appending the following function and let me know how it goes.

    add_filter( 'login_url', 'dcg_reauth1_fix' );
    function dcg_reauth1_fix($url) {
    	if ( '/wp-admin/' === add_query_arg( array() ) ) {
    		$url = remove_query_arg( 'reauth', $url );
    		$url = add_query_arg( 'redirect_to', get_admin_url(), $url );
    	}
    	return $url;
    }
    Moderator bcworkz

    (@bcworkz)

    I’m guessing something is calling wp_login_url() to get to the login form. The function accepts a force reauth parameter. You can use the “login_url” filter to alter what this function returns as an URL. The force reauth option needs to be honored, but you can implement it any way you want.

    Thread Starter beeky2

    (@beeky2)

    Unfortunatelly Dipak’s solution doesn’t work, it removes the reauth query arg but it keeps going to form login instead of admin dashboard.
    now the URL is this just without the reauth:
    https://carnielli.stranoweb.org/wp-login.php?redirect_to=https://carnielli.stranoweb.org/wp-admin/

    Moderator bcworkz

    (@bcworkz)

    The presence of the reauth argument is less of an issue than the URL itself. You would need to alter the URL returned in a way that is compatible with your login method. Maybe it’s simply the URL of the current page with a query argument that causes your modal to launch. Or maybe return the redirect URL with an action argument appended. That may end up being the same URL either way. Scripts use this function for either a link that users click on or for an URL that’s redirected to. Your login routine should accommodate these scenarios and honor any passed parameters when appropriate.

    The proper solution is less a quick fix for wp_login_url() and more part of how your plugin functions in handling logins. An important factor is the target use of your plugin. Is it specifically for one site, a limited group of sites, or general public distribution?

    Thread Starter beeky2

    (@beeky2)

    Thanks bcworkz for your reply, i’ve finally found the solution myself and it was so simple I can’t believe.

    I’ve just changed $user_signon = wp_signon( $info, false ); to $user_signon = wp_signon( $info );

    and now works!

    p.s. I’m doin the plugin for public distribution.

    Hi @beeky2,

    Glad that it’s sorted.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘developing an ajax login plugin and getting reauth=1’ is closed to new replies.