/** * Send a notification to the user for confirmation of account removal * * @param string $type what kind of removal * @param int $user_guid the user_guid to send the notification to * * @return bool */ function account_removal_send_notification($type, $user_guid) { $result = false; $site = elgg_get_site_entity(); if (!empty($user_guid) && ($user = get_user($user_guid)) && in_array($type, array("remove", "disable"))) { $token = acount_removal_generate_confirm_token($type, $user_guid); $url = elgg_get_site_url() . "account_removal/" . $type . "/?confirm_token=" . $token; $subject = elgg_echo("account_removal:message:" . $type . ":subject", array($site->name)); $message = elgg_echo("account_removal:message:" . $type . ":body", array($user->name, $url)); notify_user($user_guid, $site->getGUID(), $subject, $message, null, "email"); $result = true; } return $result; }
/** * Send a notification to the user for confirmation of account removal * * @param string $type what kind of removal * @param int $user_guid the user_guid to send the notification to * * @return bool */ function account_removal_send_notification($type, $user_guid) { $site = elgg_get_site_entity(); $user = get_user($user_guid); if (empty($user)) { return false; } if (!in_array($type, ['remove', 'disable'])) { return false; } $token = acount_removal_generate_confirm_token($type, $user_guid); if (empty($token)) { return false; } $url = elgg_normalize_url("account_removal/{$user->username}/confirm/{$type}/?confirm_token={$token}"); $subject = elgg_echo("account_removal:message:{$type}:subject", [$site->name]); $message = elgg_echo("account_removal:message:{$type}:body", [$user->name, $url]); notify_user($user_guid, $site->getGUID(), $subject, $message, null, 'email'); return true; }