MyBB Community Forums

Full Version: Plugin disable link guest
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys i know that there are a lot of plugins for MyBB that allow people to disable links for guests on their boards.

I am running MyBB 1.6.9 and cant find a single plugin to allow this.

It might just be that my links are coded as it is a rule on my site to have links coded.

Is their a plugin that will achieve this goal of making coded links hidden to guests?

If so can you please link me to / explain how to do it?

Thanks
MyBB parses posts on page load, they are stored in the db as, for example, this:

Hi guys, I [b]really[/b] need help with this [i]serious issue[/i]. My board is [url=http://www.google.com]Google[/url]

If you edited the post parser, you could do this (untested).

Find:
         $standard_mycode['url_simple']['regex'] = "#\[url\]([a-z]+?://)([^\r\n\"<]+?)\[/url\]#sei";
         $standard_mycode['url_simple']['replacement'] = "\$this->mycode_parse_url(\"$1$2\")";
 
         $standard_mycode['url_simple2']['regex'] = "#\[url\]([^\r\n\"<]+?)\[/url\]#ei";
         $standard_mycode['url_simple2']['replacement'] = "\$this->mycode_parse_url(\"$1\")";
 
         $standard_mycode['url_complex']['regex'] = "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#esi";
         $standard_mycode['url_complex']['replacement'] = "\$this->mycode_parse_url(\"$1$2\", \"$3\")";
 
         $standard_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#esi";
         $standard_mycode['url_complex2']['replacement'] = "\$this->mycode_parse_url(\"$1\", \"$2\")";

Replace with:

if($mybb->user['uid'] == 0)
{
         $standard_mycode['url_simple']['regex'] = "#\[url\]([a-z]+?://)([^\r\n\"<]+?)\[/url\]#sei";
         $standard_mycode['url_simple']['replacement'] = "\$this->mycode_parse_url(\"$1$2\")";
 
         $standard_mycode['url_simple2']['regex'] = "#\[url\]([^\r\n\"<]+?)\[/url\]#ei";
         $standard_mycode['url_simple2']['replacement'] = "\$this->mycode_parse_url(\"$1\")";
 
         $standard_mycode['url_complex']['regex'] = "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#esi";
         $standard_mycode['url_complex']['replacement'] = "\$this->mycode_parse_url(\"$1$2\", \"$3\")";
 
         $standard_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#esi";
         $standard_mycode['url_complex2']['replacement'] = "\$this->mycode_parse_url(\"$1\", \"$2\")";
}
else
{
         $standard_mycode['url_simple']['regex'] = "#\[url\]([a-z]+?://)([^\r\n\"<]+?)\[/url\]#sei";
         $standard_mycode['url_simple']['replacement'] = "hidden";
 
         $standard_mycode['url_simple2']['regex'] = "#\[url\]([^\r\n\"<]+?)\[/url\]#ei";
         $standard_mycode['url_simple2']['replacement'] = "hidden";
 
         $standard_mycode['url_complex']['regex'] = "#\[url=([a-z]+?://)([^\r\n\"<]+?)\](.+?)\[/url\]#esi";
         $standard_mycode['url_complex']['replacement'] = "hidden";
 
         $standard_mycode['url_complex2']['regex'] = "#\[url=([^\r\n\"<&\(\)]+?)\](.+?)\[/url\]#esi";
         $standard_mycode['url_complex2']['replacement'] = "hidden";
}

Find:

private function cache_mycode()
     {
         global $cache, $lang;

Replace:

private function cache_mycode()
     {
         global $cache, $lang, $mybb;

I haven't tested this.
and this method is supposed to make the urls visible for registered and logged in users but for guests the links are disabled?

And what file would these edits go into if it does make them hidden for guests but visible for logged in users.
Yes, it should.

Sorry, in inc/class_parser.php. Smile
OK thank you, I will try to do this either later tonight or tomorrow. Not sure when i will have the time to try it out.

That code dosent work.

I tried viewing a thread that had coded links in it as a guest and the links were visible. The code does not work.

Any other way to accomplish this?

Obviously myBB is a good software but when theres all kinds of functions that dont work with the newest version... Drives me nuts.