SHARE
TWEET

send email to each individual attendee using Attendee Form

eventsmanager Oct 8th, 2014 (edited) 1,391 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /*
  4.  * This function will send email to each individual attendee using Attendee Form
  5.  *
  6.  * - add form field with the following in your Forms Editor > Attendee Form
  7.  *   - Field Label => Email
  8.  *   - Field ID    => attendee_email
  9.  *  
  10.  * How to use this snippet
  11.  *   - using your host cpanel or ftp, go to wp-content > (create this folder) mu-plugins > (create this php file) functions.php
  12.  *   - edit file functions.php
  13.  *   - paste the snippet below
  14.  *  
  15.  * Booking Status:
  16.  * 0 = Pending
  17.  * 1 = Approved
  18.  * 2 = Rejected
  19.  * 3 = Cancelled
  20.  * 4 = Awaiting Online Payment
  21.  * 5 = Awaiting Payment
  22.  */
  23.  
  24. function my_em_custom_email($result, $EM_Booking){
  25. if ( $EM_Booking->booking_status == 1 ){
  26.    
  27.     $EM_Tickets_Bookings = $EM_Booking->get_tickets_bookings();
  28.     $attendee_datas      = EM_Attendees_Form::get_booking_attendees($EM_Booking);
  29.     foreach( $EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking ){
  30.         if( !empty($attendee_datas[$EM_Ticket_Booking->ticket_id]) ){
  31.             foreach( $attendee_datas[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data ){
  32.                 foreach( $attendee_data as $field_label => $field_value){
  33.                     if ( $field_label == 'Email'  ){ //this is the field label in your Forms Editor > Attendee Form
  34.                         EM_Mailer::send(
  35.                         $EM_Booking->output(get_option('dbem_bookings_email_confirmed_subject')).' - Attendee',
  36.                         $EM_Booking->output(get_option('dbem_bookings_email_confirmed_body')),
  37.                         $field_value
  38.                         );
  39.                     }
  40.                 }
  41.             }
  42.         }//END - foreach( $EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking ){
  43.     }
  44. }
  45.     return $result;
  46. }
  47. add_filter('em_booking_set_status','my_em_custom_email',100,2);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top