86d049f3 by Kevin Burton

merged 220 into tag

1 parent f3eb8d8b
......@@ -187,7 +187,7 @@ function remove_notice($notification_id = -1) {
Send Notifications
@trigger = notification unique slug name
*/
function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),$send_override = false) {
function send_triggered_notification($uid = 0,$trigger="NO_TRIGGER",$args = array(),$send_override = false) {
global $wpdb;
$notification = get_notification_by_trigger($trigger);
......@@ -231,19 +231,25 @@ function send_triggered_notification($uid,$trigger="NO_TRIGGER",$args = array(),
// if is_email ===========================================
if ($notification->is_email) {
$user = new User\Account($uid);
$email_address_preference = get_user_meta($user->ID, 'email_address_preference', true);
if (empty($email_address_preference)) {
$to_email = $user->user_email;
if ($uid == 0 && !isset($args['email'])) {
return;
} elseif ( $uid == 0 && isset($args['email']) ) {
$to_email = $args['email'];
} else {
$pp = strtolower($email_address_preference)."_";
$to_email = get_user_meta($user->ID, $pp.'email', true);
if (empty($to_email)) {
$user = new User\Account($uid);
$email_address_preference = get_user_meta($user->ID, 'email_address_preference', true);
if (empty($email_address_preference)) {
$to_email = $user->user_email;
}
} else {
$pp = strtolower($email_address_preference)."_";
$to_email = get_user_meta($user->ID, $pp.'email', true);
if (empty($to_email)) {
$to_email = $user->user_email;
}
}
}
$contents = $email;
......