/** * Save the optin/optout on Registration Form */ function alo_em_save_registration_optin($user_id, $password = "", $meta = array()) { $user = get_userdata($user_id); if (!empty($user->first_name) && !empty($user->last_name)) { $name = $user->first_name . ' ' . $user->last_name; } else { $name = $user->display_name; } if (isset($_POST['alo_em_opt']) && $_POST['alo_em_opt'] == "yes") { $lang = isset($_POST['alo_em_lang']) && in_array($_POST['alo_em_lang'], alo_em_get_all_languages(false)) ? $_POST['alo_em_lang'] : ""; $fields['email'] = $user->user_email; //edit : added all this line $fields['name'] = $name; //edit : added all this line //alo_em_add_subscriber( $fields, 1, $lang ); //edit : orig : alo_em_add_subscriber( $user->user_email, $name , 1, $lang ); if (alo_em_add_subscriber($fields, 1, $lang) == "OK") { do_action('alo_easymail_new_subscriber_added', alo_em_get_subscriber($user->user_email), $user_id); } // if subscribing, save also lists $mailinglists = alo_em_get_mailinglists('public'); if ($mailinglists) { $subscriber_id = alo_em_is_subscriber($user->user_email); foreach ($mailinglists as $mailinglist => $val) { if (isset($_POST['alo_em_register_lists']) && is_array($_POST['alo_em_register_lists']) && in_array($mailinglist, $_POST['alo_em_register_lists'])) { alo_em_add_subscriber_to_list($subscriber_id, $mailinglist); // add to list } } } } /*else { alo_em_add_email_in_unsubscribed ( $user->user_email ); }*/ }
function alo_em_handle_bounces($report = false) { global $wpdb; $output = ''; $bounce_settings = alo_em_bounce_settings(); $conn = alo_em_bounce_connect(); if (!$conn) { return FALSE; } $num_msgs = imap_num_msg($conn); // start bounce class require_once 'inc/bouncehandler/bounce_driver.class.php'; $bouncehandler = new Bouncehandler(); // get the failures $email_addresses = array(); $delete_addresses = array(); $max_msgs = min($num_msgs, $bounce_settings['bounce_maxmsg']); if ($report) { $output .= 'Bounces handled in: ' . $bounce_settings['bounce_email']; } for ($n = 1; $n <= $max_msgs; $n++) { $msg_headers = imap_fetchheader($conn, $n); $msg_body = imap_body($conn, $n); $bounce = $msg_headers . $msg_body; //entire message $multiArray = $bouncehandler->get_the_facts($bounce); if (!empty($multiArray[0]['action']) && !empty($multiArray[0]['status']) && !empty($multiArray[0]['recipient'])) { if ($report) { $output .= '<br /> - MSG #' . $n . ' - Bounce response: ' . $multiArray[0]['action']; } // If delivery permanently failed, unsubscribe if ($multiArray[0]['action'] == 'failed') { $email = trim($multiArray[0]['recipient']); // Unsubscribe email address if ($s_id = alo_em_is_subscriber($email)) { alo_em_delete_subscriber_by_id($s_id); do_action('alo_easymail_bounce_email_unsubscribed', $email); // Hook if ($report) { $output .= ' - ' . $email . ' UNSUBSCRIBED'; } } } // If delivery temporary or permanently failed, mark recipient as bounced if ($multiArray[0]['action'] == 'failed' || $multiArray[0]['action'] == 'transient' || $multiArray[0]['action'] == 'autoreply') { // TODO maybe use: $bouncehandler->x_header_search_1 = 'ALO-EM-Newsletter'; // Look fo EasyMail custom headers: Newsletter and Recipient // NOTE: searching in body because IDs are inside original message included in body $newsletter_id = 0; $recipient_id = 0; if (preg_match('/X-ALO-EM-Newsletter: (\\d+)/i', $bounce, $matches)) { if (!empty($matches[1]) && is_numeric($matches[1])) { $newsletter_id = (int) $matches[1]; } } if (preg_match('/X-ALO-EM-Recipient: (\\d+)/i', $bounce, $matches)) { if (!empty($matches[1]) && is_numeric($matches[1])) { $recipient_id = (int) $matches[1]; } } // Mark recipient as bounced only if not a debug to author if ($newsletter_id > 0 && $recipient_id > 0 && strpos($msg_headers, "( DEBUG - TO: ") === false) { $wpdb->update("{$wpdb->prefix}easymail_recipients", array('result' => -3), array('ID' => $recipient_id, 'newsletter' => $newsletter_id, 'email' => $email)); } if ($report) { $output .= ' - Recipient ID #' . $recipient_id . ' marked as not delivered'; } // mark msg for deletion imap_delete($conn, $n); } } else { if ($report) { $output .= '<br /><span class="description"> - MSG #' . $n . ' - Not a bounce</span>'; } } } //for loop // delete messages imap_expunge($conn); // close imap_close($conn); if ($report) { return $output; } }
function widget($args, $instance) { global $user_ID, $user_email, $wpdb; extract($args); // add ALO: hide the widget in subscriber page if (is_page(get_option('alo_em_subsc_page'))) { return; } if (is_page(alo_em_get_subscrpage_id(alo_em_get_language()))) { return; } //if ( is_page() ) return; // Hide widget to users, if required in setting if (get_option('alo_em_hide_widget_users') == "yes" && is_user_logged_in()) { return; } // Our variables from the widget settings. $title = apply_filters('widget_title', $instance['title']); // Get the the user's optin setting if (alo_em_is_subscriber($user_email)) { $optin_checked = "checked='checked'"; $optout_checked = ""; } else { $optin_checked = ""; $optout_checked = "checked='checked'"; } // Before widget (defined by themes). echo $before_widget; // Display the widget title if one was input (before and after defined by themes). if ($title) { echo $before_title . $title . $after_title; } // get the message optin/out messages // mod ALO: we need them also outside widget $optin_msg = get_option('alo_em_optin_msg'); $optout_msg = get_option('alo_em_optout_msg'); //$optin_msg = $instance['alo_easymail_optin_msg']; //$optout_msg = $instance['alo_easymail_optout_msg']; // add ALO: print the form echo alo_em_show_widget_form(); // and output it //echo $html; // After widget (defined by themes). echo $after_widget; }