News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[TRICK] Show an error when a guest tries to view a topic

Started by NanoSector, April 14, 2012, 04:36:33 AM

Previous topic - Next topic

NanoSector

Since this has been requested several times now, and I've posted a solution before, here goes:

In /Sources/Display.php, find this:

Code (Find) Select
// What are you gonna display if these are empty?!
if (empty($topic))
fatal_lang_error('no_board', false);


And add this after:

Code (Add after) Select
// Are we a guest?
if ($context['user']['is_guest'])
fatal_lang_error('cannot_view_topic_guest');


Then, in your Modifications.{language}.php, add this before the ?> and change the message:

$txt['cannot_view_topic_guest'] = 'The error you would like in here';

So if I'd like to have "Sorry, guest, but you are unable to view topics!" as error message, I'd put this in:

$txt['cannot_view_topic_guest'] = 'Sorry, guest, but you are unable to view topics!';

So now guests should be unable to view topics and instead get that message smashed in their face ;)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Robert.


NanoSector

Thanks, and thank you for reminding me to post a trick for it ;)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

flower12

Quote from: NanoSector on April 14, 2012, 04:36:33 AMSince this has been requested several times now, and I've posted a solution before, here goes:

In /Sources/Display.php, find this:

Code (Find) Select
// What are you gonna display if these are empty?!
if (empty($topic))
fatal_lang_error('no_board', false);

And add this after:

Code (Add after) Select
// Are we a guest?
if ($context['user']['is_guest'])
fatal_lang_error('cannot_view_topic_guest');

Then, in your Modifications.{language}.php, add this before the ?> and change the message:

$txt['cannot_view_topic_guest'] = 'The error you would like in here';
So if I'd like to have "Sorry, guest, but you are unable to view topics!" as error message, I'd put this in:

$txt['cannot_view_topic_guest'] = 'Sorry, guest, but you are unable to view topics!';
So now guests should be unable to view topics and instead get that message smashed in their face ;)

Thank you!!

Advertisement: