Chatbox

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Redirection on 12/5/2012, 4:03 pm

PorkyPine V5

avatar

Premium Member
hello,

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

thanks in advance

View user profile http://gfx-creators.forumotion.com/

2 Re: Redirection on 13/5/2012, 7:18 pm

PorkyPine V5

avatar

Premium Member
BUMP

View user profile http://gfx-creators.forumotion.com/

3 Re: Redirection on 22/5/2012, 8:58 pm

PorkyPine V5

avatar

Premium Member
BUMP

View user profile http://gfx-creators.forumotion.com/

4 Re: Redirection on 23/5/2012, 7:33 am

Drogba921

avatar

Administrator
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 -->

View user profile http://www.codinghelp.org

5 Re: Redirection on 24/5/2012, 1:27 am

PorkyPine V5

avatar

Premium Member
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?

View user profile http://gfx-creators.forumotion.com/

6 Re: Redirection on 24/5/2012, 7:34 am

Drogba921

avatar

Administrator
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

View user profile http://www.codinghelp.org

7 Re: Redirection on 24/5/2012, 4:24 pm

PorkyPine V5

avatar

Premium Member
what i ment is that, if a guesys is registering or trying to log in would he be redirected?

View user profile http://gfx-creators.forumotion.com/

8 Re: Redirection on 24/5/2012, 6:16 pm

LGforum

avatar

Moderator
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

View user profile

9 Re: Redirection on 24/5/2012, 7:21 pm

PorkyPine V5

avatar

Premium Member
Where would this go under?

View user profile http://gfx-creators.forumotion.com/

10 Re: Redirection on 24/5/2012, 7:34 pm

Rideem3

avatar

Premium Member
An announcement or widget. Wink
It won't work in the templates.

View user profile http://malware-site.www/

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

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