Forum
How to control what page users are redirected to once logged in?
Is it possible to control what page users are served up once they successfully log in using the Members app?
Is it possible to control what page users are served up once they successfully log in using the Members app?
Yes, that's down to how you put your site together. How do you have it structured?
I have a top-level navigation page that contains some standard description text about signing up for member-only access to resources. Then, on that same page have a login box in the sidebar. I want to make it so that once they enter valid credentials into the login box, and click log in, that they are directed to a hidden page that is not accessible via the top-level navigation.
Wouldn't you just check...
I am not sure if I missed something in your question so please excuse me if I have missed something.
Hi Robert, So would I just write my own redirect in PHP then? It seems like it would make sense to have some sort of parameter that can be passed into perch_members_login_form(); which could control the redirect upon successful authentication.
If writing my own PHP, is this something like what I should be looking to do: https://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php?
Sorry Ed, Didn't see your question till now. I just tested a little function added to members runtime.php that redirects if logged in... If you are comfortable with a little coding here it is... ADD this function to /perch/addons/apps/perch_members/runtime.php
THEN... ADD this bit of code directly after <?php include('perch/runtime.php'); ?> on members/index.php
Of course this is a very simple piece of code which you will need to tweak, and if you update the members app you will have to update the runtime.php too.
Ed, in this case I'm not sure this would work (of course I haven't tested) because perch has already begun outputting to the browser which means the header() has already been sent. For this reason, my example is placed right at the beginning of the page right after the call to perch runtime, before output to the browser has begun and if the member is logged in we use PerchUtil::redirect() for the redirect.
Hi Robert, I just wanted to thank you for your help with this. Although I went an alternative route to the redirect, it is helpful to have this answer out there.
Thanks again, Ed