MyBB Community Forums

Full Version: Nofollow Plugin - Dofollow for Admin posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use Nofollow plugin by Juzzi. I see that all URL's from all posts get nofollowed irrespective of the group.

Can someone please tell me the way how I can make nofollow selective? I mean, I want that URLs in posts created by admins and mods shouldn't be nofollowed.

Please let me know how I can do that.
I guess that would be complicated to implement, as nofollow usually just hooks into the URL mechanism regardless of who made the posting.

Why do you need it? What do you intend to achieve?
Just alter the function...

add this after the globals in the function.

if($mybb->user['usergroup'] == "4") { return; }

That should stop the function cold for admins posts. If you want to also include Super Moderators

if($mybb->user['usergroup'] == "4" || $mybb->user['usergroup'] == "3") { return; }
@labrocca:

I tried but didn't work..

First I tried inside the nofollow_parse function
function nofollow_parse($msg)
{
    if($mybb->user['usergroup'] == "4") { return; }
$msg = preg_replace("#<a href=\"(.+)\" target=\"_blank\">#i", "<a href=\"$1\" target=\"_blank\" rel=\"nofollow\">", $msg);
	return $msg;
}

then tried inside nofollow_info...

function nofollow_info()
{
	return array(
		"name"			=> "NoFollow",
		"description"	=> "Adds a rel=\"nofollow\" attribute to user posted links.",
		"website"		=> "http://www.msgweb.nl",
		"author"		=> "Juzzi",
		"authorsite"	=> "http://www.msgweb.nl",
		"version"		=> "1.0",
	);
if($mybb->user['usergroup'] == "4") { return; }
}

Seems I didn't get what you mean by add after 'globals in the function'

@frostschutz: Why do you need it? What do you intend to achieve?

I thought the need was quite self-explanatory. Tell me, why did Google introduce nofollow at the first place? So that you can say to SE's that see though I am linking to this site but I 'm not sure about its credibility and don't pass any PR juice from my site... that's what I intend to do... I'm sure about the credibility of sites I am linking to but can't be always sure of the sites my forum members might be linking to.

Trust it is clear now?
You might have to use global $mybb; before using the $mybb in a function. Still I'm not sure wether this is going to work. You need to check the group of the user that made the posting that is currently parsed; not the group of the current user.
frost is correct...

add globals
function nofollow_parse($msg)
{
global $mybb;

    if($mybb->user['usergroup'] == "4") { return; }
$msg = preg_replace("#<a href=\"(.+)\" target=\"_blank\">#i", "<a href=\"$1\" target=\"_blank\" rel=\"nofollow\">", $msg);
    return $msg;
}
Still it is not working... now it has made all links dofollowed means it has removed nofollow from all the links Sad

am reverting to nofollow till we get some solution