• Resolved uclackitech

    (@uclackitech)


    Hi

    I’m trying to add a custom conditional placeholder if an event has a ticket description or not. I created a custom placeholder for the ticket description called #EVENTTICKETS and that works on its own. But, the conditional placeholder does not seem to be working.

    {has_ticketdescription}#EVENTTICKETS{/has_ticketdescription}

    Here’s my code. I formatted it based on this: https://wordpress.org/support/topic/conditional-placeholder-for-_eventnotes?replies=5

    add_action('em_event_output_condition', 'filterEventOutputCondition', 1, 4);
    function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
    	if( is_object($EM_Ticket) && preg_match('/^has_ticketdescription/',$condition, $matches) ){
    		if ( !empty($EM_Ticket->ticket_description) ){
    			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
    		}else{
    			$replacement = '';
    		}
    	}
    	return $replacement;
    }

    But for some reason, it does not seem to be working.

    Thank you for the great plugin and support!

    https://wordpress.org/plugins/events-manager/

Viewing 1 replies (of 1 total)
  • Thread Starter uclackitech

    (@uclackitech)

    Figured it out on my own.

    add_action('em_event_output_condition', 'filterEventOutputCondition', 1, 4);
    function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
    	$EM_Tickets = $EM_Event->get_tickets();
    	foreach($EM_Tickets as $EM_Ticket){
    	if( is_object($EM_Ticket) && preg_match('/^has_ticketdescription/',$condition, $matches) ){
    		if ( !empty($EM_Ticket->ticket_description) ){
    			$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
    		}else{
    			$replacement = '';
    		}
    		}
    	}
    	return $replacement;
    }

    Thanks though

Viewing 1 replies (of 1 total)

The topic ‘Ticket description custom conditional placeholder’ is closed to new replies.