You are here

function pm_email_notify_privatemsg_message_recipient_changed in Privatemsg 6.2

Same name and namespace in other branches
  1. 7.2 pm_email_notify/pm_email_notify.module \pm_email_notify_privatemsg_message_recipient_changed()

Implements hook_privatemsg_message_recipient_changed().

Notifies users who were added to a message about new Private Messages via Email.

File

pm_email_notify/pm_email_notify.module, line 201
Notifies users about new Private Messages via Email.

Code

function pm_email_notify_privatemsg_message_recipient_changed($mid, $thread_id, $recipient_id, $type, $added) {
  $types = array(
    'user',
  );

  // Only send mail if the recipient was added.
  if ($added) {
    if ($message = privatemsg_message_load($mid)) {

      // Check if we should send an email to 'hidden' recipients.
      if (!_pm_email_notify_only_user($recipient_id)) {
        $types[] = 'hidden';
      }
      if (in_array($type, $types) && _pm_email_notify_send_check($recipient_id, $message) && ($recipient = privatemsg_user_load($recipient_id))) {
        pm_email_notify_send_mail($recipient, $message);
      }
    }
  }
}