Advertisement
bastetmilo

Anniversary mail

Apr 5th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1. add_filter( 'app_message_headers', 'custom_headers_anv' );
  2.  
  3. function custom_headers_anv( $message_headers ){
  4. $message_headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
  5. return  $message_headers;
  6. }
  7.     function annv_follow_up( $value ) {
  8.     global $wpdb, $appointments;
  9.  
  10.     $a = $appointments;
  11.     // Double check if A+ is active
  12.     if ( !is_object( $a ) )
  13.     return;
  14.  
  15.     // Follow up time in hours
  16.     $month = 11;
  17.     // Follow up email subject
  18.     $subject = 'We Would Like to Hear From You!';
  19.     // Follow up email message
  20.     $message = '<center><img src="http://kidsclub4fun.com/newsite/wp-content/uploads/2015/05/kidsclublogo-hi-res.jpg" width="221" height="129"></center><br />
  21. <br />Thank you for having your party with Kids Club Fun and Fitness. We would like to see how we did! Below is a link to a survey that will let us know how our performance was.<br />
  22. <br />
  23. <a href="http://kidsclub4fun.com/birthday-party-customer-feedback/">Birthday Party Feedback</a><br />
  24. <br />
  25. Warm Regards,<br />
  26. Kids Club Fun and Fitness<br />
  27. (360)-546-5437';
  28.  
  29.     $results = $wpdb->get_results( "SELECT * FROM " . $a->app_table . " WHERE note NOT LIKE '%Follow up sent%' AND
  30.  
  31. status='completed' AND DATE_ADD(created, INTERVAL ".$month." MONTH) <'" . date ("Y-m-d H:i:s", $a->local_time ). "' " );
  32.     if ( $results ) {
  33.     foreach ( $results as $r ) {
  34.     // Send email
  35.     if ( wp_mail( $r->email, $subject, $message, $a->message_headers() ) ) {
  36.     // Save so that we don't send email again
  37.     $wpdb->update ( $a->app_table,
  38.     array( 'note' => $r->note . ' Anniversary reminder sent' ),
  39.     array( 'ID' => $r->ID ),
  40.     array ( '%s' )
  41.     );
  42.         // Log here for better results
  43.         $appointments->log ( sprintf( "Follow up email sent to %s for appointment ID %s" , $r->email , $r->ID ) ) ;
  44.     }
  45.     }
  46.     }
  47.     }
  48.     add_action( 'update_option_app_last_update', 'annv_follow_up' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement