Redirection

View previous topic View next topic Go down

PorkyPine V5
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
http://gfx-creators.forumotion.com/

PostPorkyPine V5 12/5/2012, 2:03 pm

hello,

i was wondering if there is a code that would redirect ONLY guests to a certain page

thanks in advance
PorkyPine V5
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
http://gfx-creators.forumotion.com/

PostPorkyPine V5 13/5/2012, 5:18 pm

BUMP
PorkyPine V5
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
http://gfx-creators.forumotion.com/

PostPorkyPine V5 22/5/2012, 6:58 pm

BUMP
Mike
Mike
Administrator
Forum Posts : 446
Member Since : 2011-10-28
http://www.codinghelp.org

PostMike 23/5/2012, 5:33 am

Yeah there is! If you have PHPBB2 or PunBB you can use this code in your TEMPLATES.

Code:
<!-- BEGIN switch_user_logged_out --><script type="text/javascript">
window.location = "PAGELINK"
</script><!-- END switch_user_logged_out -->
PorkyPine V5
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
http://gfx-creators.forumotion.com/

PostPorkyPine V5 23/5/2012, 11:27 pm

2 more questions:

what template does this go under

and would this affect the person if they try to log in or register

ex: one guest gets redirected and then registers, would he get redirected back?
Mike
Mike
Administrator
Forum Posts : 446
Member Since : 2011-10-28
http://www.codinghelp.org

PostMike 24/5/2012, 5:34 am

It will only direct them if they're not logged into the forum, which would make them guests. You can put this in a variety of places..

IF you don't want them to be able to view the forum at all, put it in Overall_header

If you don't want them to view topics put it in Viewtopic_body
PorkyPine V5
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
http://gfx-creators.forumotion.com/

PostPorkyPine V5 24/5/2012, 2:24 pm

what i ment is that, if a guesys is registering or trying to log in would he be redirected?
LGforum
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12

PostLGforum 24/5/2012, 4:16 pm

Don't put it in the overall header, as then when he is on the register page or log in page, yes he'll still get redirected.

The better way would be a javascript route. Something like this in an announcement:
Code:

<script>
var is_logged_in=('{USERNAME}'!='Guest');
(function(){
  var p = window.location.pathname.substr(1);
  if(p.length && p != 'login' && p != 'register' && !is_logged_in) {
    window.location = '/redirect page';
  }
})();
</script>
This won't redirect them if they're on the register or log in page, or homepage.

It will also provide you with a global variable stating if the user if logged in or not for use in other Javascripts Wink
PorkyPine V5
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
http://gfx-creators.forumotion.com/

PostPorkyPine V5 24/5/2012, 5:21 pm

Where would this go under?
Rideem3
Rideem3
Premium Member
Premium Member
Forum Posts : 8
Member Since : 2011-12-28
http://malware-site.www/

PostRideem3 24/5/2012, 5:34 pm

An announcement or widget. Wink
It won't work in the templates.
Sponsored content

PostSponsored content

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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