How to redirect to a specified page

Discussion in 'Templates customization' started by bdmc, Mar 30, 2012.

  1. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    Where in the code I can make changes so when an user signs in, I can redirect him to the proper web page? By example, if user wants to see a specific web page, he needs to log in first, then he will be redirected to this page
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    amember CP -> Setup -> Login Page -> Redirect after Login.
  3. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    This just works for ONE single redirect. Where I can add many other redirects?
  4. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,435
    Are you using V3 or 4? Where are they logging in from?

    David
  5. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    I am using V4. The member logs in from the login form and then is redirected to the specified page.
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    You can add additional amember_redirect_url parameter to your login form.
    Or specify it in url when you redirect user to aMember's login page:
    /amember/login/?amember_redirect_url=/url/
  7. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    >>You can add additional amember_redirect_url parameter to your login form.
    Where is the login form? There are many logn.phtml files that are similar, but which one does the redirect ?
  8. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Sorry but I'm not sure what are you trying to do? I thought you have custom login form and what control where user will be redirected after login from that form.
    Please explain how you want it to work.
  9. bdmc

    bdmc New Member

    Joined:
    Mar 23, 2012
    Messages:
    20
    >>amember CP -> Setup -> Login Page -> Redirect after Login
    This works for one single redirect.

    I want to have other redirects. Is there a way to modify the login form to include other redirections?

    I figured out that in order to have other redirects, I had to modify some links. I just modified one that should redirect the user to a protected page. When the user clicks on this link, he is redirected to the login form, but not redirected back to the page he wanted to see. 2 days ago it worked, but that's because the page had a *html extension and was not even protected from unauthorized use.

    Today I changed this page to a *php extension and still used the same link. Unfortunatelly after the user was logged in, he was not able to access the desired page and it ended in a server loop.

    I had to add this code to the page I wanted to protect.

    PHP:
    <?php
    session_start
    ();

    if(!isset(
    $_SESSION['login']))
        {
        
    header("Location: http://signipedia.com/amember/login?amember_redirect_url=http://signipedia.com/fable4.php");
        exit;
        }
    ?>
    Now I don't understand why the user is not redirected back to this protected page. If the page is unprotected, he can access it, but if the page is protected, it does not work. Do you have any idea?

    I hope my explanation is a little more clearer.
  10. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Please see my reply in other thread

Share This Page