Redirection

View previous topic View next topic Go down

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

PostPorkyPine V5 on 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
avatar
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
View user profile http://gfx-creators.forumotion.com/

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

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

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

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

PostMike on 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 -->
avatar
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
View user profile http://gfx-creators.forumotion.com/

PostPorkyPine V5 on 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?
avatar
Mike
Administrator
Forum Posts : 446
Member Since : 2011-10-28
View user profile http://www.codinghelp.org

PostMike on 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
avatar
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
View user profile http://gfx-creators.forumotion.com/

PostPorkyPine V5 on 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?
avatar
LGforum
Moderator
Forum Posts : 77
Member Since : 2011-11-12
View user profile

PostLGforum on 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
avatar
PorkyPine V5
Premium Member
Premium Member
Forum Posts : 14
Member Since : 2011-12-19
View user profile http://gfx-creators.forumotion.com/

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

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

PostRideem3 on 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