Created
February 14, 2014 02:30
-
-
Save sidharrell/8994796 to your computer and use it in GitHub Desktop.
add email newsletter filter (is being added in 3.1.38)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this goes in includes/admin-files/event_newsletter.php at line 49 (approx) | |
<li> | |
<select name="filter"> | |
<option value="all"><?php _e("All attendees of this event", "event_espresso"); ?></opton> | |
<option value="completed"><?php _e("Completed payment status attendees", "event_espresso"); ?></opton> | |
<option value="incomplete"><?php _e("Incomplete payment status attendees", "event_espresso"); ?></opton> | |
<option value="pending"><?php _e("Pending payment status attendees", "event_espresso"); ?></opton> | |
</select> | |
</li> | |
// line 6 of that same file changes to: | |
espresso_event_reminder($event_id, $_POST['email_subject'], $_POST['email_text'], $email_name, $_POST['filter']); | |
// This is a pluggable function in email.php, so you can put this function into uploads/espresso/custom_functions.php: | |
function espresso_event_reminder($event_id, $email_subject='', $email_text='', $email_id=0, $filter="all") { | |
global $wpdb, $org_options; | |
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); | |
$count = 0; | |
switch ($filter) { | |
case "completed": | |
$sql_filter = " AND payment_status='Completed'"; | |
break; | |
case "incomplete": | |
$sql_filter = " AND payment_status='Incomplete'"; | |
break; | |
case "pending": | |
$sql_filter = " AND payment_status='Pending'"; | |
break; | |
default: | |
$sql_filter = ""; | |
} | |
$SQL = 'SELECT * FROM ' . EVENTS_ATTENDEE_TABLE . ' WHERE event_id =%d' . $sql_filter . ' GROUP BY lname, fname'; | |
$attendees = $wpdb->get_results( $wpdb->prepare( $SQL, $event_id )); | |
if ($wpdb->num_rows > 0) { | |
foreach ($attendees as $attendee) { | |
$attendee_id = $attendee->id; | |
event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'false', 'send_attendee_email' => 'true', 'custom_data' => array('email_type' => 'reminder', 'email_subject' => $email_subject, 'email_text' => $email_text, 'email_id' => $email_id))); | |
$count++; | |
} | |
?> | |
<div id="message" class="updated fade"> | |
<p><strong> | |
<?php echo sprintf(_n('Email Sent to 1 person successfully.', 'Email Sent to %d people successfully.', $count, 'event_espresso'), $count); ?> | |
</strong></p> | |
</div> | |
<?php | |
return; | |
} else { | |
?> | |
<div id="message" class="error fade"> | |
<p><strong> | |
<?php _e('No attendee records available.', 'event_espresso'); ?> | |
</strong></p> | |
</div> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment