I need a "redirect after log in" code
+3
Ange Tuteur
Take Notes
OMMA
7 posters
Page 1 of 1
I need a "redirect after log in" code
Is there a java code or a template edit that I can use to redirects members to a certain page after they log in? What I mean is if a person is reading a certain thread as a guest and decides they want to post, they log in and are redirected to that thread so they can post. As of now when they log in they are redirected to the index. This means they have to click their way back to the thread they wanted to post in. I would like people to be redirected to the last page they were viewing once they log in.
Re: I need a "redirect after log in" code
The login widget should do that. I'm pretty sure if they login through that widget, they will be directed to the same page.
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
Re: I need a "redirect after log in" code
Thanks for your reply. I tried it and no it still redirects to the index. I do not want to add a widget to the forums though. I want this to be done with the normal log in from the navigation bar.
Re: I need a "redirect after log in" code
Hi @OMMA,
Try the following.
Go to Modules > JavaScript codes management and create a new script with these settings :
Placement : In all the pages
To change the redirect URL simply modify the redirect variable.
Try the following.
Go to Modules > JavaScript codes management and create a new script with these settings :
Placement : In all the pages
- Code:
/\/login/.test(window.location.href) && $(function() {
var redirect = '/forum';
if (!_userdata.session_logged_in) {
$('form[name="form_login"]')[0].redirect = redirect;
}
});
To change the redirect URL simply modify the redirect variable.
Re: I need a "redirect after log in" code
Thanks Ange but it didn't work. Still redirects to the index. Basically what I'm trying to do is lessen the amount of clicks to get to specific pages. Right now if someone is viewing a certain page and log in they are redirected to the index and have to click their way back to the page they were on to post. I guess the portal or an HTML page could be a HUB that is used for shortcuts but I cant get either to work. I've made them both the homepage and also activated them but when I log in it still always redirects to the index so I'm basically trying to find a workaround. If you can help me get the portal or homepage to always show up when a person registers or logs in that would be great though.
Re: I need a "redirect after log in" code
Is the script still installed ? I checked your forum, but I didn't see any installed scripts. Just to be sure, make certain that JS codes management is enabled.
The option will be above the installed script list.
The option will be above the installed script list.
Re: I need a "redirect after log in" code
Are you wanting where everyone is redirected to what they are reading as a guest?
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: I need a "redirect after log in" code
What the member is asking for if i have this right is.
Say im looking at this post as a guest and i think Wow i want to post in this thread and i lick login now it will log me in but take me to the home page.
what the member want is to stay right here and get to type in this thread without going back to the home / forum page.
come to think of it i want the same thing for my sites LOL
Say im looking at this post as a guest and i think Wow i want to post in this thread and i lick login now it will log me in but take me to the home page.
what the member want is to stay right here and get to type in this thread without going back to the home / forum page.
come to think of it i want the same thing for my sites LOL
Re: I need a "redirect after log in" code
Find this line in your overal_header template
- Code:
<script src="{JS_DIR}{L_LANG}.js" type="text/javascript"></script>
- Code:
<script type="text/javascript">document.write('<input type="hidden" name="redirect" value="' + location.href + '" />')</script>
Re: I need a "redirect after log in" code
Just paste this
- Code:
<script type="text/javascript">document.write('<input type="hidden" name="redirect" value="' + location.href + '" />')</script>
Re: I need a "redirect after log in" code
Yes this exactly.APE wrote:What the member is asking for if i have this right is.
Say im looking at this post as a guest and i think Wow i want to post in this thread and i lick login now it will log me in but take me to the home page.
what the member want is to stay right here and get to type in this thread without going back to the home / forum page.
come to think of it i want the same thing for my sites LOL
@SarkZKalie it didn't work. I'm still taken to the index when I log in.
Re: I need a "redirect after log in" code
Yes. If a person is reading a thread as a guest and decides he wants to joi the discussion he logs in and is redirected to that thread instead of to the index.SLGray wrote:Are you wanting where everyone is redirected to what they are reading as a guest?
@SarkZKalie that didn't work either. I'm still sent to the index when I log in.
Re: I need a "redirect after log in" code
Hmm.. I think I understand what you mean now. Try giving the following script a try :
Placement : In all the pages
The last page visited is stored to a cookie, except while viewing the login page. So, once you click onto the login page it should set the redirect value to the previously viewed page. Let me know if that's what you want.
Placement : In all the pages
- Code:
$(function() {
if (!_userdata.session_logged_in) {
if (/\/login/.test(window.location.href)) {
var form = document.form_login, cookie = my_getcookie('fa_last_page');
if (form) form.redirect.value = cookie ? cookie : '';
} else {
my_setcookie('fa_last_page', window.location.pathname);
}
}
});
The last page visited is stored to a cookie, except while viewing the login page. So, once you click onto the login page it should set the redirect value to the previously viewed page. Let me know if that's what you want.
Re: I need a "redirect after log in" code
Yes that's it! Thank you very much Ange. You are an awesome guy on these forums. You seem to have all the answers. Thanks again. This can be marked as solved now.
Re: I need a "redirect after log in" code
Topic solved and archived
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» When i paste a long code via [code][/code] the page expands
» Log in Redirect
» help in this code . the effect on code > add button to Put under the colored writing
» Hide Code? or Post to See Content Code?
» Redirect
» Log in Redirect
» help in this code . the effect on code > add button to Put under the colored writing
» Hide Code? or Post to See Content Code?
» Redirect
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum