MyBB Community Forums

Full Version: Custom moderation tools PMs from specific user
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone!

Is there a way to make the custom moderation tools send the PMs from a specific user, rather than the user who issued the command (I think that's what it does currently, could be wrong?)? If so, how can I do it?

Thanks in advance!

Best wishes,
Hm, is this something that can't be done?


I managed to figure it out! In case anyone else is wondering how to do this, this is what I did:

In the file root/inc/class_custommoderation.php I changed line 492
send_pm($pm, $mybb->user['uid'], 1);
send_pm($pm, 4, 1);

The second parameter is the user ID it send the PM from. You search for the user you want all PMs to be sent from (in my case it's a user called System) and you set that value to the user's ID.

Also, I was bummed by the fact that I couldn't use {subject} in the PM body like I can in the new reply, so here's what I did:
// For each thread, we send a PM to the author
$query = $db->simple_select("threads", 'uid, subject', "tid IN ($tid_list)");
while($thread = $db->fetch_array($query))
	// Let's send our PM
	$message = $thread_options['pm_message'];
	$message = str_ireplace('{subject}', $thread['subject'], $message);
	$message = str_ireplace('{link}', ''.$tid.'.html', $message);
	$subject = $thread_options['pm_subject'];
	$subject = str_ireplace('{subject}', $thread['subject'], $subject);
	$subject = str_ireplace('{link}', ''.$tid.'.html', $subject);
	$pm = array(
		'subject' => $subject,
		'message' => $message,
		'touid' => $thread['uid'],
	send_pm($pm, 4, 1);

What this does is it replaces {subject} with the thread subject and {link} with the link to the thread. Note that the latter only works if you have the .htaccess provided with MyBB enabled!

Hope this helps someone who is wondering the same thing I was wondering!