MyBB Community Forums
Plugin Function Question - 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: Plugin Function Question (/thread-69617.html)



Plugin Function Question - Aaron - 2010-05-14

function test_do()
{
   global $mybb,$db,$user_info;
	
		require_once MYBB_ROOT."inc/datahandlers/pm.php";
		$pmhandler = new PMDataHandler();
		
		$subject = "test";
		$message = "you have been done wooo hahaahahaah";
		
		$pm = array(
			"subject" => $subject,
			"message" => $message,
			"icon" => -1,
			"toid" => 1,
			"fromid" => $mybb->user['uid'],
			"do" => '',
			"pmid" => ''
		);
		$pm['options'] = array(
			"signature" => "1",
			"disablesmilies" => "0",
			"savecopy" => "0",
			"readreceipt" => "0"
		);
				
		$pmhandler->set_data($pm);

		if(!$pmhandler->validate_pm())
		{
		$pm_errors = $pmhandler->get_friendly_errors();
		$send_errors = inline_error($pm_errors);
		echo $send_errors;
		}
		else
		{
			$pminfo = $pmhandler->insert_pm();
		}
		unset($pm);
		unset($pmhandler);
   
}

The function/hook is working where it should because if i add echo "test"; to the end it is displaying on the page. Any idea why this doesn't send a PM, no error displayed either.


RE: Plugin Function Question - Diogo Parrinha - 2010-05-14

Does echo $send_errors; echo anything?


RE: Plugin Function Question - Aaron - 2010-05-14

No, bit strange! also added

	
else
		{
			$pminfo = $pmhandler->insert_pm();
			echo "TEST";
		}

under the insert echo and that echos, so theres no error in the insert, it just doesn't do it!


RE: Plugin Function Question - Diogo Parrinha - 2010-05-14

Search for a PM function I posted on this forum and try it, can't be bothered to search and compare right now Toungue


RE: Plugin Function Question - Aaron - 2010-05-14

Just had a search, not finding much.
Found it, let me look!
Just seen your script, how would i run the function, how would the array look..


RE: Plugin Function Question - Diogo Parrinha - 2010-05-14

Simple, just look at how it checks the array inside the function.
You have to pass an uid, a message, a subject and something else. Just check the function Smile