Redirect URL on login

Discussion in 'Setting-up protection' started by jp_kirby, Apr 1, 2015.

  1. jp_kirby

    jp_kirby New Member

    Joined:
    Mar 7, 2015
    Messages:
    3
    I have embedded a login form using HTML form action on two of the pages on my site and would like users to be redirected back to the page they logged in from, but instead it goes back to the main page (the "fixed URL" I specified in the admin centre).

    amember_redirect_url does not work, and when I leave the fixed URL blank it goes to the member page.

    Any advice?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    amember_redirect_url parameter indeed should work in this situation.
    Can you copy & paste your form code here.
  3. jp_kirby

    jp_kirby New Member

    Joined:
    Mar 7, 2015
    Messages:
    3
    Sure:

    <form method=post action='/new/amember/login?amember_redirect_url=(URL)'>
    <table><tr><td>Username:</td><td><input type=text name=amember_login size=20></td></tr>
    <tr><td>Password:</td><td><input type=password name=amember_pass size=20></td></tr></table>
    <input type=submit value='Login'>
    </form>
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    So do not pass it in action. Just add another hidden to form:
    Code:
    <form method=post action='/new/amember/login'> 
    <table><tr><td>Username:</td><td><input type=text name=amember_login size=20></td></tr> 
    <tr><td>Password:</td><td><input type=password name=amember_pass size=20></td></tr></table>
    <input type=submit value='Login'> 
    <input type=hidden name='amember_redirect_url' value='(URL)'>
    </form>
    
  5. jp_kirby

    jp_kirby New Member

    Joined:
    Mar 7, 2015
    Messages:
    3
    Thanks, it works.
  6. stockgumshoe

    stockgumshoe aMember Pro Customer

    Joined:
    Apr 10, 2008
    Messages:
    1
    This doesn't seem to work for me. We just upgraded from V3 and the hidden redirect was "redirect_to". I changed as follows:

    Code:
    <form name="loginform" id="loginform" action="/premium/member.php" method="post">
                    <p class="login-username">
                        <input type="text" name="amember_login" id="user_login" class="input" value="" size="20" tabindex="10">
                    </p>
                    <p class="login-password">
                        <input type="password" name="amember_pass" id="user_pass" class="input" value="" size="20" tabindex="11">
                    </p>
                    <p class="login-submit">
                        <input type="submit" id="wp-submit" class="button-primary" value="Login" tabindex="12">
                        <input type='hidden' name='amember_redirect_url' value='http://mysite.com'>
                    </p>
                </form>
    Apologies for the excess <p> tags, inherited code. But this doesn't redirect to mysite, it just lands us on member.
    Last edited: Sep 10, 2015
  7. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,670
    Please replace
    Code:
    action="/premium/member.php"
    with
    Code:
    action="/premium/login"

Share This Page