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.
+3
Ange Tuteur
Take Notes
OMMA
7 posters
I need a "redirect after log in" code
OMMA- Forumember
- Posts : 59
Reputation : 1
Language : English
Location : USA
- Post n°1
I need a "redirect after log in" code
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
The login widget should do that. I'm pretty sure if they login through that widget, they will be directed to the same page.
OMMA- Forumember
- Posts : 59
Reputation : 1
Language : English
Location : USA
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.
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
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.
OMMA- Forumember
- Posts : 59
Reputation : 1
Language : English
Location : USA
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.
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
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.
SLGray- Administrator
- Posts : 51554
Reputation : 3524
Language : English
Location : United States
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.
Ape- Administrator
- Posts : 19435
Reputation : 2010
Language : fluent in dork / mumbojumbo & English haha
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
SarkZKalie- Support Moderator
- Posts : 1443
Reputation : 220
Language : English
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>
Pamoon- Forumember
- Posts : 28
Reputation : 10
Language : en.js
- Post n°10
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>
OMMA- Forumember
- Posts : 59
Reputation : 1
Language : English
Location : USA
- Post n°11
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.
SarkZKalie- Support Moderator
- Posts : 1443
Reputation : 220
Language : English
- Post n°12
Re: I need a "redirect after log in" code
Try this tutorial or you can do as Forumedic says
OMMA- Forumember
- Posts : 59
Reputation : 1
Language : English
Location : USA
- Post n°13
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.
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°14
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.
OMMA- Forumember
- Posts : 59
Reputation : 1
Language : English
Location : USA
- Post n°15
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.
SLGray- Administrator
- Posts : 51554
Reputation : 3524
Language : English
Location : United States
- Post n°16
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.