Advertisement:

Author Topic: [Trick] Redirect guests to the login page when trying to view a topic  (Read 4831 times)

Offline Doctor Deejay

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 3,491
  • Gender: Male
Index.php
Find
Code: [Select]
// Board is not empty... topic is not empty... action is empty.. Display!
else
{
require_once($sourcedir . '/Display.php');
return 'Display';
}
Replace with
Code: [Select]
// Board is not empty... topic is not empty... action is empty.. Display!
elseif(!empty($topic) && $context['user']['is_logged'])
{
require_once($sourcedir . '/Display.php');
return 'Display';
}
elseif(!empty($topic) && !$context['user']['is_logged']) {
require $sourcedir . '/LogInOut.php';
return 'Login';
}
And change
Code: [Select]
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedirTo
Code: [Select]
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $contextNot heavily tested but should work :) Actually it shows the login page rather than redirecting, but it has the same effect.
« Last Edit: April 16, 2012, 12:43:21 PM by 医生唱片骑师 »
Doctor Deejay                                        I understand everything... except that wig. - Jack Sparrow
Simple Machines LocalizerDon't pm me for support
deejay [at] simplemachines [dot] orgGet To Know The Team - Dr. Deejay

Offline Doctor Deejay

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 3,491
  • Gender: Male
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #1 on: April 15, 2012, 12:42:31 PM »
I have also packaged this in a mod and submitted this to the mod site. :)
Doctor Deejay                                        I understand everything... except that wig. - Jack Sparrow
Simple Machines LocalizerDon't pm me for support
deejay [at] simplemachines [dot] orgGet To Know The Team - Dr. Deejay

Offline Spectrum..!!

  • Charter Member
  • SMF Hero
  • *
  • Posts: 5,569
  • Gender: Male
  • No to Bullying !!
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #2 on: April 15, 2012, 08:28:52 PM »
Good, very good trick.

Thank you.

Existem pessoas que deixam de buscar algo que dura a vida toda, para somente conquistar algo que dura alguns momentos...
Ser humilde; não é ser menos que alguém. É saber que não somos mais que ninguém!
SMF 2.0.4 | Meu site -->
Dell Vostro 3560 + AMD Radeon™ HD 7670M 1GB| Windows 8 Pro | Fedora 18 | IE10 | Google Chrome
Não atendo PM para pedidos de suporte/ajuda

Online Colin

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 4,693
  • Gender: Male
  • SMF and Web Hosting Enthusiast
    • Gray Web Host
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #3 on: April 15, 2012, 08:33:06 PM »
Very helpful. Thanks!
https://www.graywebhost.com - Affordable, reliable hosting starting at $2.95 per month

Offline phantomm

  • Sr. Member
  • ****
  • Posts: 882
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #4 on: April 16, 2012, 04:55:45 AM »
I'm just curious, what is the difference between Hide Topics from Guests and this trick?
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Doctor Deejay

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 3,491
  • Gender: Male
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #5 on: April 16, 2012, 07:45:52 AM »
You're welcome :)

@Phantomm: this mod has a very small difference in functionality. This mod just shows a login page when a guest tries to read topics. Hide Topics from Guests is a more advanced mod. :P

Just wondering though, does anyone have problems with this trick? I haven't got problems with it myself, but I was told that admins can't see topics either. =/ Doesn't happen to me though
Doctor Deejay                                        I understand everything... except that wig. - Jack Sparrow
Simple Machines LocalizerDon't pm me for support
deejay [at] simplemachines [dot] orgGet To Know The Team - Dr. Deejay

Offline soumarin

  • Newbie
  • *
  • Posts: 1
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #6 on: April 17, 2012, 10:18:15 PM »
thanks i hade the same question

Offline Doctor Deejay

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 3,491
  • Gender: Male
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #7 on: April 18, 2012, 01:14:02 AM »
You're welcome :)
Doctor Deejay                                        I understand everything... except that wig. - Jack Sparrow
Simple Machines LocalizerDon't pm me for support
deejay [at] simplemachines [dot] orgGet To Know The Team - Dr. Deejay

Offline phantomm

  • Sr. Member
  • ****
  • Posts: 882
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #8 on: April 18, 2012, 03:54:25 AM »
and what if I want redirect guests to the login page only in selected boards?
is there any way to do this?
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Doctor Deejay

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 3,491
  • Gender: Male
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #9 on: April 18, 2012, 04:35:28 AM »
Yup, but it would require a few extra edits. I'm quite busy with other stuff right now, but I will look into it when I have some time. :)
Doctor Deejay                                        I understand everything... except that wig. - Jack Sparrow
Simple Machines LocalizerDon't pm me for support
deejay [at] simplemachines [dot] orgGet To Know The Team - Dr. Deejay

Offline phantomm

  • Sr. Member
  • ****
  • Posts: 882
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #10 on: April 18, 2012, 04:56:13 AM »
thanks ;)
Polskie wsparcie SMF na simplemachines.org

My mods

Offline shubha

  • Jr. Member
  • **
  • Posts: 207
  • Gender: Male
Re: [Trick] Redirect guests to the login page when trying to view a topic
« Reply #11 on: April 20, 2012, 11:53:49 PM »
Thanks but already a mod is there.  "Look but no read".

Offline fifacluborg

  • Newbie
  • *
  • Posts: 9
PLEASE HELP ME
« Reply #12 on: May 02, 2012, 09:21:24 AM »
And change
Code: [Select]
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedirTo
Code: [Select]
global $modSettings, $settings, $user_info, $board, $topic, $board_info, $maintenance, $sourcedir, $contextNot heavily tested but should work :) Actually it shows the login page rather than redirecting, but it has the same effect.
I not find this line! Can anyone tell me what file I find?
I did have searched in index.php and I not found nothing there... :(

Offline Doctor Deejay

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 3,491
  • Gender: Male
You can find that in the index.php in the root of your forum (there are multiple index.php, each directory has one :P). ;) Also, I'm planning to release an updated version soon (Thanks Labradoodle :) ). ;D
Doctor Deejay                                        I understand everything... except that wig. - Jack Sparrow
Simple Machines LocalizerDon't pm me for support
deejay [at] simplemachines [dot] orgGet To Know The Team - Dr. Deejay