Skip to content

Instantly share code, notes, and snippets.

@tommm
Created October 22, 2012 14:40
Show Gist options
  • Save tommm/3931813 to your computer and use it in GitHub Desktop.
Save tommm/3931813 to your computer and use it in GitHub Desktop.
MyBB: Get recipients and their respective PMIDs
$plugins->add_hook('datahandler_pm_insert', 'pm_insert');
$plugins->add_hook('private_do_send_end', 'pm_private_end');
function pm_insert($handler)
{
global $cache;
static $last_uid;
if(!isset($cache->cache['pmcache']))
{
// Hijack the cache for our dastardly plan
$cache->cache['pmcache'] = array();
}
if(!empty($handler->pmid))
{
// Update the PMID for the last user
$cache->cache['pmcache'][$last_uid] = array('uid' => $last_uid, 'pmid' => $handler->pmid);
}
$last_uid = $handler->pm_insert_data['toid'];
}
function pm_private_end()
{
global $mybb, $pmhandler;
// pm_insert doesn't handle the last recipient but we still have the data; update it.
$pm = $pmhandler->pm_insert_data;
$pmcache = $mybb->cache->read('pmcache');
$pmcache[$pm['toid']] = array('user' => $pm['toid'], 'pmid' => $pmhandler->pmid);
// $pmcache now contains all recipients and their respective PMIDs
print_r($pmcache);
die;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment