• Resolved EliotNieto

    (@eliotnieto)


    I added some custom attributes to the Locations like Phone Number, emai and Facebook Page. I like to show them, but as they’re optional fields, first I have to check if the value is set.
    I tried this code in functions.php file of my theme:

    function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){
        if( is_object($EM_Location) && preg_match('/^hay_telefonou/',$condition, $matches) ){
                /* if ( !empty($EM_Location->location_region) ){ */
            if( !in_array($args['Telefono Ubicacion'],$EM_Location->location_attributes) && !empty($EM_Location->location_attributes['Telefono Ubicacion'])){
                    $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
                }else{
                    $replacement = '';
                }
            }
            return $replacement;
        }
    add_action('em_location_output_condition', 'filterLocationOutputCondition', 1, 4);

    Where ‘Telefono Ubicacion’ means Location Phone

    The code in location template is the following:

    {hay_telefonou}<strong>TELEFONO:</strong><br>#_ATT{Telefono Ubicacion}{/hay_telefonou}

    The output can see in this page.

    Hope someone can help me, and sorry for my bad english.

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    here’s another thread which may help you with this – http://wordpress.org/support/topic/conditional-has_region?replies=9

    Thread Starter EliotNieto

    (@eliotnieto)

    Thanks for your answer, at first time, I’ve tried this solution, but it didn’t work. I think I’m doing something wrong. I changed the custom attribute UbicacionTel (without space) for doing easier.
    This is the code I added in the functions.hp file, (I highlighted the changes I’ve done in bold)

    add_action('em_location_output_condition', 'filterLocationOutputCondition', 1, 4);
        function filterLocationOutputCondition($replacement, $condition, $match, $EM_Location){
            if( is_object($EM_Location) && preg_match('/^<strong>hay_telefonou</strong>/',$condition, $matches) ){
                if ( is_array($EM_Location-><strong>UbicacionTel</strong>) && !empty($EM_Location-><strong>UbicacionTel</strong>) ){
                    $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
                }else{
                    $replacement = '';
                }
            }
            return $replacement;
        }

    But it doesn’t show anything.
    I also tried to show the attribute directly as
    #_ATT{UbicacionTel}
    but it doesn’t show correctly.
    Please, hope someone help me and tell me what I’m doing wrong.

    Thread Starter EliotNieto

    (@eliotnieto)

    In addition, I have the following attributes for the Locations in General Options page:

    #_ATT{UbicacionFacebook}
    #_ATT{UbicacionEmail}
    #_ATT{UbicacionTel}
    #_ATT{UbicacionWeb}

    The ‘Enable location attributes’ and ‘Enable location custom fields?’ options are checked YES, but when I add a new location, at the Attributes pane I get the following message:
    ‘In order to use attributes, you must define some in your templates, otherwise they’ll never show. Go to Events > Settings > General to add attribute placeholders.’

    Is there any setting that I have missed?
    Thank you.

    Have you added the custom attributes to Events > Settings > General > Event Attributes?

    Thread Starter EliotNieto

    (@eliotnieto)

    I added some custom attributes for the Events and other custom attributes for the Locations. But when I add a new Event, I see the custom attributes for the Events and the Locations. Example

    Events > Settings > General >

    Custom attributes for events
    #_ATT{E1}
    #_ATT{E2}
    #_ATT{E3}

    Custom attributes for locations
    #_ATT{L1}
    #_ATT{L2}
    #_ATT{L3}

    Adding a New Event:

    Attributes Pane:
    —————-
    Attribute Name | Value
    E1:
    E2:
    E3:
    L1:
    L2:
    L3:
    —————

    Add a new location:

    Attributes Pane:
    —————-
    In order to use attributes, you must define some in your templates……
    —————

    I don’t want to add location attributes for the events, so I don’t know what I’m doing wrong.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    for location, should something like #_LATT{L1} at Settings > General > Location Attributes

    Thread Starter EliotNieto

    (@eliotnieto)

    Thank you!! I apologize for the inconveniences. That worked fine.. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Location Custom Attributes’ is closed to new replies.