Advertisement
eventsmanager

custom conditional placeholder gender

May 27th, 2014
581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. /*
  2. * CHANGE field_id with your forms editor field id
  3. * CHANGE male or female with your own text/value eg. mr or mrs
  4. */
  5. add_action('em_event_output_condition', 'my_em_booking_meta_male_event_output_condition', 1, 4);
  6. function my_em_booking_meta_male_event_output_condition($replacement, $condition, $match, $EM_Event){
  7. if( is_object($EM_Event) && preg_match('/^is_male/',$condition, $matches) ){
  8. $replacement = '';
  9. foreach($EM_Event->get_bookings() as $EM_Booking){
  10. if ( $EM_Booking->booking_meta['booking']['field_id'] == 'male' ){
  11. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  12. }
  13. }
  14. }
  15. return $replacement;
  16. }
  17. add_action('em_event_output_condition', 'my_em_booking_meta_female_event_output_condition', 1, 4);
  18. function my_em_booking_meta_female_event_output_condition($replacement, $condition, $match, $EM_Event){
  19. if( is_object($EM_Event) && preg_match('/^is_female/',$condition, $matches) ){
  20. $replacement = '';
  21. foreach($EM_Event->get_bookings() as $EM_Booking){
  22. if ( $EM_Booking->booking_meta['booking']['field_id'] == 'female' ){
  23. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  24. }
  25. }
  26. }
  27. return $replacement;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement