Advertisement
eventsmanager

has_location_x (location_id)

Feb 13th, 2023
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * usage: {has_location_31} TEST {/has_location_31} where 31 is the Location ID
  5. */
  6.  
  7. add_action('em_event_output_condition', 'my_em_event_output_condition', 1, 4);
  8. function my_em_event_output_condition($replacement, $condition, $match, $EM_Event){
  9. if( preg_match('/^has_location_([a-zA-Z0-9_\-,]+)$/',$condition, $location_id_match) ){
  10. if( $EM_Event->get_location()->location_id == $location_id_match[1] ){
  11. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  12. }else{
  13. $replacement = '';
  14. }
  15. }
  16. return $replacement;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement