The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

I need a "redirect after log in" code

+3
Ange Tuteur
Take Notes
OMMA
7 posters

Go down

Solved I need a "redirect after log in" code

Post by OMMA Fri 5 Feb - 15:15

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
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 Take Notes Fri 5 Feb - 15:56

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
Take Notes
Helper
Helper

Male Posts : 2337
Reputation : 324
Language : English
Location : Forumountain

Back to top Go down

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

Post by OMMA Fri 5 Feb - 16:33

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
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 Fri 5 Feb - 16:55

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
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

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

Post by OMMA Fri 5 Feb - 17:39

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
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 Fri 5 Feb - 17:48

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.
I need a "redirect after log in" code Captur20
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

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

Post by SLGray Fri 5 Feb - 18:09

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


I need a "redirect after log in" code Slgray10

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

Male Posts : 51568
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

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

Post by Ape Fri 5 Feb - 21:01

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


I need a "redirect after log in" code Left1212I need a "redirect after log in" code Center11I need a "redirect after log in" code Right112
I need a "redirect after log in" code Ape_b110
I need a "redirect after log in" code Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19450
Reputation : 2011
Language : fluent in dork / mumbojumbo & English haha

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

Back to top Go down

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

Post by SarkZKalie Fri 5 Feb - 23:29

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


I need a "redirect after log in" code Sarkzk10
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1446
Reputation : 220
Language : English

https://rotavn.forumotion.com/

Back to top Go down

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

Post by Pamoon Sat 6 Feb - 9:01

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
Pamoon
Forumember

Posts : 28
Reputation : 10
Language : en.js

https://help.forumotion.com/

Back to top Go down

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

Post by OMMA Sat 6 Feb - 16:15

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
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 Sat 6 Feb - 20:50

Try this tutorial or you can do as Forumedic says
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1446
Reputation : 220
Language : English

https://rotavn.forumotion.com/

Back to top Go down

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

Post by OMMA Wed 10 Feb - 0:54

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
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 Wed 10 Feb - 10:31

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
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

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

Post by OMMA Fri 19 Feb - 18:14

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
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 Fri 19 Feb - 18:15

Topic solved and archived


I need a "redirect after log in" code Slgray10

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

Male Posts : 51568
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

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