You are here

function apply_for_role_send_email in Apply for role 7.2

Custom function for sending an email out

Parameters

$reason: A string to be passed determining which reason you are sending an email and thus pulling in necessary values

$uid: User id of the user applying for the role

$rid: Role id that the user is being approved for.

3 calls to apply_for_role_send_email()
apply_for_role_approve_apply in ./apply_for_role.module
Approve a role application and put the user into the role.
apply_for_role_deny_apply in ./apply_for_role.module
Deny a role application.
apply_for_role_process_applications in ./apply_for_role.module
Process an application and store it for admin review.

File

./apply_for_role.module, line 819
Allows users to apply for roles.

Code

function apply_for_role_send_email($reason, $uid, $rid = null) {
  if ($uid !== NULL && is_numeric($uid)) {
    $user = user_load($uid);
    switch ($reason) {
      case 'admin':
        $superAdmin = user_load(1);
        $adminEmails = variable_get('apply_for_role_custom_admin_email');
        if (!$adminEmails) {
          $to = $superAdmin->mail;
        }
        else {
          $to = $adminEmails;
        }
        break;

      // This is for apply and deny
      default:
        $to = $user->mail;
        break;
    }
    drupal_mail('apply_for_role', $reason, $to, language_default(), array(
      'rid' => $rid,
      'user' => $user,
    ));
  }
}