eventsmanager

custom conditional placeholder gender

May 27th, 2014
360
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×