Advertisement
eventsmanager

Conditional Placeholder: has_owner_x

Jan 7th, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. /*
  2.  
  3. This custom conditional placeholder shows the format per booking spaces available
  4.  
  5. sample usage:
  6. {has_owner_x}
  7. Test
  8. {/has_owner_x}
  9.  
  10. where x is the user id
  11. */
  12. add_action('em_event_output_condition', 'my_em_custom_event_output_condition', 1, 4);
  13. function my_em_custom_event_output_condition($replacement, $condition, $match, $EM_Event){
  14. if( is_object($EM_Event) && preg_match('/^has_owner_([a-zA-Z0-9_\-]+)$/',$condition, $matches) ){
  15. if( $EM_Event->get_contact()->ID == $matches[1] ){
  16. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  17. }else{
  18. $replacement = '';
  19. }
  20. }
  21. return $replacement;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement