The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

I need a "redirect after log in" code

View previous topic View next topic Go down

Solved I need a "redirect after log in" code

Post by OMMA on February 5th 2016, 8:15 pm

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.

OMMA
Forumember

Male Posts : 59
Reputation : 1
Language : English
Location : USA

http://omma.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by Genesis on February 5th 2016, 8:56 pm

The login widget should do that. I'm pretty sure if they login through that widget, they will be directed to the same page.

Genesis
Forum Reviewer
Forum Reviewer

Male Posts : 2331
Reputation : 322
Language : English
Location : Forumountain

http://forumpromocean.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by OMMA on February 5th 2016, 9:33 pm

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.

OMMA
Forumember

Male Posts : 59
Reputation : 1
Language : English
Location : USA

http://omma.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by Ange Tuteur on February 5th 2016, 9:55 pm

Hi @OMMA,

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.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by OMMA on February 5th 2016, 10:39 pm

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.

OMMA
Forumember

Male Posts : 59
Reputation : 1
Language : English
Location : USA

http://omma.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by Ange Tuteur on February 5th 2016, 10:48 pm

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.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by SLGray on February 5th 2016, 11:09 pm

Are you wanting where everyone is redirected to what they are reading as a guest?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35613
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by APE on February 6th 2016, 2:01 am

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 Razz





APE
Manager
Manager

Male Posts : 8309
Reputation : 716
Language : fluent in dork / mumbojumbo & English haha
Location : STUCK IN FORUMOTIONS SERVERS HELP ME !!!!!!

http://chatworld.forumotion.co.uk/

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by SarkZKalie on February 6th 2016, 4:29 am

Find this line in your overal_header template
Code:
<script src="{JS_DIR}{L_LANG}.js" type="text/javascript"></script>
Then, add this code after it
Code:
<script type="text/javascript">document.write('<input type="hidden" name="redirect" value="' + location.href + '" />')</script>
Save and publish it! Twisted Evil

SarkZKalie
Forumember

Male Posts : 419
Reputation : 73
Language : English

http://rotavn.nstars.org/

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by Pamoon on February 6th 2016, 2:01 pm

Just paste this
Code:
<script type="text/javascript">document.write('<input type="hidden" name="redirect" value="' + location.href + '" />')</script>
before </form> in your login form if youre using a custom login.

Pamoon
Forumember

Posts : 25
Reputation : 10
Language : en.js

http://animoe.twilight-mania.com/

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by OMMA on February 6th 2016, 9:15 pm

@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 Razz
Yes this exactly.

@SarkZKalie it didn't work. I'm still taken to the index when I log in.

OMMA
Forumember

Male Posts : 59
Reputation : 1
Language : English
Location : USA

http://omma.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by SarkZKalie on February 7th 2016, 1:50 am

Try this tutorial or you can do as Forumedic says

SarkZKalie
Forumember

Male Posts : 419
Reputation : 73
Language : English

http://rotavn.nstars.org/

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by OMMA on February 10th 2016, 5:54 am

@SLGray wrote:Are you wanting where everyone is redirected to what they are reading as a guest?
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.

@SarkZKalie that didn't work either. I'm still sent to the index when I log in.

OMMA
Forumember

Male Posts : 59
Reputation : 1
Language : English
Location : USA

http://omma.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by Ange Tuteur on February 10th 2016, 3:31 pm

Hmm.. I think I understand what you mean now. Try giving the following script a try :

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.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by OMMA on February 19th 2016, 11:14 pm

Yes that's it! cheers 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.

OMMA
Forumember

Male Posts : 59
Reputation : 1
Language : English
Location : USA

http://omma.forumotion.com

Back to top Go down

Solved Re: I need a "redirect after log in" code

Post by SLGray on February 19th 2016, 11:15 pm

Topic solved and archived


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 35613
Reputation : 2372
Language : English
Location : United States

http://fmthemes.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum