• Hi,
    first of all thx for this great plugin !
    After hours searching in support forum i decide to ask. I have 3 custom attributes to manage contact informations for my events : contact-nom, contact-tel and contact-mail.
    I would like to show contact informations only if one of the 3 information is filled. for example :

    {has_contact-nom} OR {has_contact-tel} OR {has_contact-mail} // display contact infos

    for the moment i have this :

    <div class="event-contact">
    <h3>Contact</h3>
    <p>
    {has_contact-nom} #_ATT{contact-nom} {/has_contact-nom}<br />
    {has_contact-tel} <i class="fa fa-phone"></i> #_ATT{contact-tel} {/has_contact-tel}<br />
    {has_contact-mail} <i class="fa fa-envelope-o"></i> <a href="mailto: #_ATT{contact-mail}">#_ATT{contact-mail}</a> {/has_contact-mail}
    </p>
    </div>

    but if the 3 contact informations are empty i still have the contact title which is no more necessary.

    Thx for Help

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Glad you’re enjoying the plugin.

    I think the only solution fo this would be to create a custom conditional placeholder that checks to see if at least one of the custom attributes is set.

    This should help:
    https://wp-events-plugin.com/tutorials/creating-conditional-placeholders-for-events/

    Thread Starter fredleput

    (@fredleput)

    Hi, thx for reply.
    Here’s my custom conditionnal placeholders function :

    // conditionnal tag for contact custom field in events
    function em_event_output_condition_filter($replacement, $condition, $match, $EM_Event){
        // Checks for has_contact-nom conditional
        if(is_object($EM_Event) && preg_match('/^has_(contact-nom)$/', $condition, $matches)){
            if(array_key_exists($matches[1], $EM_Event->event_attributes) && !empty($EM_Event->event_attributes[$matches[1]]) ){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }	
    
    	// Checks for has_contact-tel conditional
        if(is_object($EM_Event) && preg_match('/^has_(contact-tel)$/', $condition, $matches)){
            if(array_key_exists($matches[1], $EM_Event->event_attributes) && !empty($EM_Event->event_attributes[$matches[1]]) ){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
    	
    	// Checks for has_contact-email conditional
        if(is_object($EM_Event) && preg_match('/^has_(contact-mail)$/', $condition, $matches)){
            if(array_key_exists($matches[1], $EM_Event->event_attributes) && !empty($EM_Event->event_attributes[$matches[1]]) ){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
        
        return $replacement;
    }
    add_filter('em_event_output_condition', 'em_event_output_condition_filter', 1, 4);

    Will try to it by myself but any help is appreciated ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom conditionnal tag with OR operator ?’ is closed to new replies.