MyBB Community Forums

Full Version: Need help with editud to check for group.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Ooops...I do need help.

I am trying to check if the last editor of a post is a moderator.

$post['edituid']

I am doing this inside a plugin.  What I want is for my function to execute ONLY if the last editor of the post was a moderator (group 3 4 or 6).

Any help is appreciated...this is pretty much the last step of my mod before it's completed.

I will release it as soon as I get this figured out.
NVM...I do need some help.

I guess what I am asking is ..what's the easiest way to check if $post['edituid'] is a moderator inside a plugin function?
get_moderator_permissions($fid, $uid)

or

is_moderator($fid, $action, $uid)
Well here is the basics of my mod.  What it does is show a mod alert.  What I haven't been able to accomplish is having edituid checked to make sure they are in mod group to allow for the tags to display. I want to do that to prevent non-mods from using the tag.  The variations I have tried from your code above so far hasn't hit home.  I incredibly appreciate the assistance though.  This plugin is almost done.  I just need this last if statement to work.

function mod_warning($message)
{

	global $mybb, $pid, $tid, $post, $ismod, $fid;

$uid = $post['edituid'];

if (is_moderator($uid)) {

	$canshowmod = "1";
}
	if($canshowmod == "1") {



 $message = preg_replace("#\[mod\](.*?)\[/mod\]#i", "<table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td style=\"background: #FF0000;color: #FFFF00; width: 1px;\" rowspan=\"2\"><span style=\"font-weight: bold; font-family: Times New Roman, Verdana; font-size: 32px; color: #ffff00;\">&nbsp;!&nbsp;</span></td><td style=\"background: #FF0000;color: #FFFF00;\"><b>This is a moderator message.</b></td></tr><tr><td style=\"background: #FF0000;color: #FFFF00;\">$1</td></tr></table>", $message);

 $message = preg_replace("#\[mod=(.*?)\](.*?)\[/mod\]#i", "<table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td style=\"background: #FF0000;color: #FFFF00; width: 1px;\" rowspan=\"2\"><span style=\"font-weight: bold; font-family: Times New Roman, Verdana; font-size: 32px; color: #ffff00;\">&nbsp;!&nbsp;</span></td><td style=\"background: #FF0000;color: #FFFF00;\"><b>This is a moderator message from: $1</b></td></tr><tr><td style=\"background: #FF0000;color: #FFFF00;\">$2</td></tr></table>", $message);


	return $message;

	}

}
function mod_warning($message)
{

	global $mybb, $pid, $tid, $post, $ismod, $fid;
        $uid = $post['edituid'];

        if (is_moderator($post['fid'], $uid)) 
        {
             $message = preg_replace("#\[mod\](.*?)\[/mod\]#i", "<table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td style=\"background: #FF0000;color: #FFFF00; width: 1px;\" rowspan=\"2\"><span style=\"font-weight: bold; font-family: Times New Roman, Verdana; font-size: 32px; color: #ffff00;\">&nbsp;!&nbsp;</span></td><td style=\"background: #FF0000;color: #FFFF00;\"><b>This is a moderator message.</b></td></tr><tr><td style=\"background: #FF0000;color: #FFFF00;\">$1</td></tr></table>", $message);

 $message = preg_replace("#\[mod=(.*?)\](.*?)\[/mod\]#i", "<table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td style=\"background: #FF0000;color: #FFFF00; width: 1px;\" rowspan=\"2\"><span style=\"font-weight: bold; font-family: Times New Roman, Verdana; font-size: 32px; color: #ffff00;\">&nbsp;!&nbsp;</span></td><td style=\"background: #FF0000;color: #FFFF00;\"><b>This is a moderator message from: $1</b></td></tr><tr><td style=\"background: #FF0000;color: #FFFF00;\">$2</td></tr></table>", $message);

	return $message;
	}
}
Well that's pretty close to what I have been trying given you hint but so far no luck. Your code above isn't working either.

I am testing this with a single thread...I have one posted edited by a moderator member with the mod tag...then I have a regular member edit their post...with an attempt to use a mod tag...now what SHOULD happen is the mod tag edited by the regular member shouldn't display..but it does.

I wonder if this is a global problem...I can get the function to echo all the variables I need though to run the is_moderator function. Trial and error so far has only produced errors for this last element.

Thank you for anything you can do on this.
Are you sure that user isn't a moderator for any forum?
Yes.

http://www.pokemonboard.com/showthread.php?tid=157


That's my testing thread. I have tried all kinds of methods to get this to work but so far I have only managed to get a stomach ache. I know that $post['edituid'] is returning properly in the function to each post. I am echoing a lot of results to get this to work.

You may see a "tell me (no)" or "tell me (yes)" in the thread. The idea is that I know I hit it right when I get yes and no in the thread vs all the same responses. And yes..I have tried your code above as well as numerous varieties.

I wonder if the functions themselves are the problem?

Thank you again for any insight you may have to this problem.
can you try echo "Is Moderator: ".is_moderator($post['fid'], $uid); somewhere in the function.
Yes I have tried that...it displays the logged in users YES or NO. I am testing with 2 browsers...on one I am logged in as a moderator and the others as a normal user.

$uid needs to be $post['edituid']

Now I know that the functions pulls $post['edituid'] BUT...I don't know if the $post['edituid'] is being pushed or used properly in the is_moderator() function.

I am trying to rebuild the is_moderator() function directly in the plugin and attemting to simply use $post['edituid'] instead of $uid. So far now luck.
Pages: 1 2