function wp_new_user_notification($user_id, $plaintext_pass = '') { $user = new WP_User($user_id); global $ym_mm_wp_new_user_notification_login; $ym_mm_wp_new_user_notification_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $ym_mm_wp_new_user_notification_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); if (empty($plaintext_pass)) { return; } $current_welcome = get_option('ym_other_mm_welcome'); $subject = $current_welcome->subject; $message = $current_welcome->message; add_shortcode('blogname', 'mailmanager_shortcode_blogname'); add_shortcode('blogurl', 'mailmanager_shortcode_blogurl'); $subject = do_shortcode($subject); add_shortcode('loginurl', 'wp_login_url'); add_shortcode('login', 'mailmanager_shortcode_user'); global $ym_mm_wp_new_user_notification_password; $ym_mm_wp_new_user_notification_password = $plaintext_pass; global $ym_mm_custom_field_user_id; $ym_mm_custom_field_user_id = $user_id; add_shortcode('password', 'mailmanager_shortcode_pass'); add_shortcode('ym_mm_custom_field', 'mailmanager_custom_fields_shortcode'); add_shortcode('ym_mm_if_custom_field', 'mailmanager_custom_fields_shortcode'); $message = do_shortcode($message); // hook into send mailmanager_send_email($user_email, $subject, $message); }
function ym_mm_parse_and_send($user_id, $subject, $message) { $data = get_userdata($user_id); $user_email = $data->user_email; add_shortcode('blogname', 'mailmanager_shortcode_blogname'); add_shortcode('blogurl', 'mailmanager_shortcode_blogurl'); add_shortcode('loginurl', 'wp_login_url'); add_shortcode('ym_mm_custom_field', 'mailmanager_custom_fields_shortcode'); add_shortcode('ym_mm_if_custom_field', 'mailmanager_custom_fields_shortcode'); add_shortcode('ym_mm_type', 'ym_mm_type_shortcode'); add_shortcode('ym_mm_title', 'ym_mm_title_shortcode'); add_shortcode('ym_mm_cost', 'ym_mm_cost_shortcode'); $subject = do_shortcode($subject); $message = do_shortcode($message); // hook into send mailmanager_send_email($user_email, $subject, $message); }
function mailmanager_check_series_queue() { $mm_action = $_GET['mm_action']; if ($mm_action) { echo __('The MM Check Series Queue is being manually run', 'ym_mailmanager') . '<br />'; } global $wpdb; // contains a element with target email_id $emails_to_send = array(); //get series $sql = 'SELECT id, recipient_list FROM ' . $wpdb->prefix . 'mm_series WHERE enabled = 1'; foreach ($wpdb->get_results($sql) as $row) { //get target users if ($sql = mailmanager_get_sql($row->recipient_list)) { if ($users = $wpdb->get_results($sql)) { foreach ($users as $i => $user) { if ($mm_action) { echo '<br />' . __('Found', 'ym_mailmanager') . ' ' . $user->email; } //add users not in table $user_id = mailmanager_get_user_id($user->email); // when did user join series $user_join = mailmanager_get_user_in_series($user_id, $row->id, $row->recipient_list); if ($user_join) { if ($mm_action) { echo ' ' . __('user is subscribed', 'ym_mailmanager'); } // get what has been sent to this users $sql = 'SELECT email_id FROM ' . $wpdb->prefix . 'mm_email_sent WHERE user_id = ' . $user_id; $ignore = array(); foreach ($wpdb->get_results($sql) as $sent) { $ignore[] = $sent->email_id; } // series emails $sql = 'SELECT email_id, delay_days FROM ' . $wpdb->prefix . 'mm_email_in_series WHERE series_id = ' . $row->id; $emails = array(); $one_day = 86400; foreach ($wpdb->get_results($sql) as $email) { $offset = $email->delay_days * $one_day; $send_email = $user_join + $offset; // already sent this email id? if (!in_array($email->email_id, $ignore)) { // check if need senting if ($send_email <= time()) { $emails[] = $email->email_id; } } } // emails now contains the emails in this series that are due to be sent // in theory this should only be a array of size 1 // depends how many emails of day delay 0 there are foreach ($emails as $email_id) { if ($mm_action) { echo ' ' . __('sending EID:', 'ym_mailmanager') . $email_id; } list($subject, $body) = mailmanager_process_hooks($email_id, $row->id, $user_id); mailmanager_send_email($user->email, $subject, $body); mailmanager_log_email_send($user_id, $email_id); } } } } } } }