Log in

View Full Version : Text only viewable by logged in users


shiznatix
10-11-2007, 06:10 AM
I have a forum post that I would like to make for a tournament but in this post I have to give out a password. Now I don't want just anybody browsing the forums to see the password, I want it to be only visible if you are logged into the forums. So if I was NOT logged in and went to this thread it would look something like this:

Blah blah blah blah blah blah
password: *you must be logged in*
Blah blah blah blah blah blah

but if I WAS logged in, it would look like this:

Blah blah blah blah blah blah
password: super_awesome_password
Blah blah blah blah blah blah

Is there a mod or something that can give me this or should I start diving into the class_bbcode.php and hope for the best? I have tried making a custom bbcode tag but it won't parse PHP

Triky
10-11-2007, 09:41 AM
Just editing your template: use this code..


<if condition="$show['member']">

Password: 123

<else />

You must to be logged in.

</if>

;)

Dismounted
10-11-2007, 09:58 AM
Yes, but he wants it in a specific thread.

shiznatix
10-11-2007, 10:19 AM
Yes, but he wants it in a specific thread.

yes exactally. Is there a way to put some template stuff like that in a post if you are a moderator?

--------------- Added at 12:32 ---------------

I made this quick hack to use a bb code tag for this. It just goes like this:


/************************************************** *********
This is Andrews section for a custom [usersonly] bb code tag
************************************************** **********/
if (false !== strpos($post['pagetext'], '[usersonly]') && false !== strpos($post['pagetext'], ''))
{
session_start();
if (!empty($_SESSION['user']['user']['logged_in']))
{
$post['pagetext'] = str_replace('', '', $post['pagetext']);
$post['pagetext'] = str_replace('', '', $post['pagetext']);
}
else
{
$post['pagetext'] = preg_replace('#\[usersonly\](.*)\[/usersonly\]#', '*You must be logged in to view this*', $post['pagetext']);
}

$post['pagetext_html'] = '';
}
/************************************************** *********
End Andrews section for a custom [usersonly] bb code tag
************************************************** **********/

And I put that in the appropriate places for viewing in hybrid mode, threaded, and regular. Is there an easier way to do this or not because this hack seams like a bit too much.