phpBB3 Hide Links from Guests

Posted on October 19th, 2009
Written by Richard
Posted in: N/A (old archives)

Ok, I figured out how to hide url links from guests in phpBB3. You can redirect those links to wherever you want (like a registration page, or whatever). Go to includes/bbcode.php, and find the function bbcode_tpl_replace. Toward the top add a new static array:

static $guest_replacements = array(
‘url’ => array(’{URL}’ => ‘http://www.movethemarkets.com’, ‘{DESCRIPTION}’ => ‘(No links for Guests)’),
‘email’ => array(’{EMAIL}’ => ‘nobody@noplace’, ‘{DESCRIPTION}’ => ‘(No emails for Guests)’)
);

… then later in that function, at the line where it says:

if (!empty($replacements[$tpl_name]))

…leave that line in, but change what that if-block does to something like this:

if( (empty($user->data['is_registered']) ||
!empty($user->data['is_bot'])) &&
!empty($guest_replacements[$tpl_name]) )
{
$tpl = strtr($tpl, $guest_replacements[$tpl_name]);
}
else {
$tpl = strtr($tpl, $replacements[$tpl_name]);
}

Now guests and bots will see your non-link, while registered users will see the full post!

Comments

blog comments powered by Disqus