WordPress.org

Ready to get started?Download WordPress

Forums

Login With Ajax
Adding %LASTURL% into Global Login Redirect (10 posts)

  1. eljkmw
    Member
    Posted 3 years ago #

    I understand that the latest version allows %LASTURL% to be added into Global Logout Redirect. But is it possible to add %LASTURL% into Global Login Redirect too?

    Please advise. Thank you in advance.

    Cheers,
    Jason

    http://wordpress.org/extend/plugins/login-with-ajax/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    I think that's possible already, give it a try?

  3. eljkmw
    Member
    Posted 3 years ago #

    Tried it. But sadly after logging in, the user is automatically directly to 'wp-admin'.
    Not sure what is causing this to happen. Any ideas?

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    works for me. maybe another plugin conflict?

  5. eljkmw
    Member
    Posted 3 years ago #

    I've checked all my activated plugins, and none seem to interfere with your plugin. I'm using WP 3.1, and I want Subscribers to be redirected to their last visited Page/Post. However, they aren't logging in via your Widget, but through the WP-Login.php page. I'm guessing that:

    1. The WP core could be overriding your plugin's login redirection, or
    2. The %LASTURL% has to be redirected 2 pages back rather than 1 (meaning that it's to back pass the "WP-Login.php" page first, and then the last visited page).

    Could the latter be the case?

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    the plugin redirects to the same page the user logged into (i guess you can call it refresh). this overrides the wp default redirect, which is not a refresh.

    If people log in through the normal login with that redirect, it'll refresh the login but then wp will redirect you to the dashboard.

  7. eljkmw
    Member
    Posted 3 years ago #

    Looks like I guessed right about the latter case. If that's the case, where can I modify the %LASTURL% redirection to back the URL twice, instead of once?

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    LoginWithAjax::getLogoutRedirect(), modify the str_replace

  9. eljkmw
    Member
    Posted 3 years ago #

    Cheers, mate =)

  10. eljkmw
    Member
    Posted 3 years ago #

    Hi Marcus,

    I just realised that it isn't the 'getLogoutRedirect()' function, but rather the 'getLoginRedirect()'. I don't have any problems with the former function though.

    In login-with-ajax/login-with-ajax.php, I found the 'getLoginRedirect()' function:

    function getLoginRedirect($user){
    		$data = $this->data;
    		if($data['login_redirect'] != ''){
    			$redirect = $data["login_redirect"];
    		}
    		if( strtolower(get_class($user)) == "wp_user" ){
    			$user_role = array_shift($user->roles); //Checking for role-based redirects
    			if( isset($data["role_login"][$user_role]) ){
    				$redirect = $data["role_login"][$user_role];
    			}
    		}
    		//Do string replacements
    		$redirect = str_replace('%USERNAME%', $user->user_login, $redirect);
    		$redirect = str_replace("%LASTURL%", $_SERVER['HTTP_REFERER'], $redirect);
    		return $redirect;
    	}

    How do I amend the 'str_replace', so that it goes back twice to the last visited page? Please advise. Thank you.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic