MyBB Community Forums
Calling unapprove_posts function in plugin - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: Calling unapprove_posts function in plugin (/thread-132694.html)



Calling unapprove_posts function in plugin - Zash - 2013-01-13

Hi,

What would be the best approach to using the unapprove_posts function within a plugin that is hooked to the post datahandler?

I want a post to be unapproved immediately upon being posted.


RE: Calling unapprove_posts function in plugin - Omar G. - 2013-01-13

You will need to hook at newreply_do_newreply_end and initialize the moderation class and make sure to check if the post is visible.
function foo()
{
	global $postinfo, $url, $lang;

	if($postinfo['visible'] == -2)
	{
		// Draft post
	}
	elseif($postinfo['visible'] == 1)
	{
			// Visible post
	}
	else
	{
			// Moderated post
	}

	require_once MYBB_ROOT.'inc/class_moderation.php';
	$moderation = new Moderation;

	$moderation->unapprove_posts($postinfo['pid']);
}

Code is incomplete, hope it to be enough Smile