Advertisement
Beee

custom placeholder function

Mar 21st, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. // function to create #_CUSTEVENTPRICE
  2. function my_em_ticket_price($replace, $EM_Event, $result) {
  3.   if ( $result == '#_CUSTEVENTPRICE' ) {
  4.         global $EM_Event;
  5.         $is_open = $EM_Event->get_bookings()->is_open(); // whether there are any available tickets right now
  6.     if ( $is_open ) { // if bookings are enabled and available
  7.         $ticketprice = do_shortcode('[event id="'.$EM_Event->event_id.'"]#_EVENTPRICEMIN[/event]');
  8.     } else { // if bookings are enabled but not available
  9.             global $post;
  10.             $ticketprice = get_post_meta($post->ID, 'Registration fee', true); // get value from custom attribute
  11.     }
  12.     $replace = $ticketprice;
  13.   }
  14.   return $replace;
  15. }
  16. add_filter('em_event_output_placeholder','my_em_ticket_price', 1, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement