Events Manager
[resolved] Conditional use of #_EVENTURL (12 posts)

  1. cucocreative
    Posted 4 years ago #

    Hi all

    New to Events Manager (5.1.6) and trying to customise the events listing page.

    My client has two types of events – free and paid. A free listing will not have a link to a single events page and will only appear in the events listing page with the limited information displayed there. A paid listing will have a more button using the default #_EVENTURL to create the link.

    The question is how to make this button appear on condition of a custom field being checked for the event.

    I have created a custom field "events_more_button", which can be blank or return a 'Yes' value. On a normal WP php template I would just add:

    <?php $key="events_more_button"; $value = get_post_meta($post->ID, $key, true);  if (!empty($value)) { ?>
    	<a class="button icon small fRight" href="#_EVENTURL"><span class="arrow">More</span></a>
    <?php } ?>

    This would display nothing if the custom field is empty, but if it is 'Yes' you would see the button.

    How do I add in this functionality? I can't use php code within EM>Setting>Formats/Layouts>Events Format>Default event list format, so how can this be achieved?

    Any advice much appreciated.


  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 4 years ago #

  3. cucocreative
    Posted 4 years ago #

    thanks for that link, but it not enough of "an idiots guide" for me. I'm not that hot on php unless it's really spelt out for me.

    I found this page earlier but was unable to untangle/understand to code enough to use it for my purpose. What do I need to swop out with my custom field, or is it more complex than that?

  4. agelonwl
    Posted 4 years ago #

  5. cucocreative
    Posted 4 years ago #

    @angelonwl Thanks, but that seems to be about a different issue. I want to display the #_EVENTURL only on some of the events (within the events listing page) dependent on whether a custom field has data or is empty.

  6. agelonwl
    Posted 4 years ago #

  7. cucocreative
    Posted 4 years ago #

    thanks again, but not quite what I need. I can add the button but I need it to show conditionally, ie only on some events.

    As events really are a custom post and use custom fields, I think it will be easier to just write my own events listing page template using default WP Loop. That might be quicker in the long run.

  8. cucocreative
    Posted 4 years ago #

    Hmmm that way seems the simplest solution. Just need to figure out how to get the start/end times custom field names into the std WP loop...

  9. cucocreative
    Posted 4 years ago #

    Nope, that's not going to work, as I need to link to specific days from the calendar which will bypass that template. So having to go back to plan A.

    I did find a more easily understandable explanation about conditional placeholders, here: http://snippets.webaware.com.au/snippets/events-manager-conditional-placeholders-for-custom-attributes

    but I can't get that code to work, you can see my comment at the bottom of that post.

  10. cucocreative
    Posted 4 years ago #

    Got it working with the solution from the other blog (see above post).

    This was the conditional statement:

    function filterEventOutputCondition($replacement, $condition, $match, $EM_Event){
    if (is_object($EM_Event)) {
    switch ($condition) {
    // #_ATT{Premium}
    case 'has_att_premium':
    if (is_array($EM_Event->event_attributes) && !empty($EM_Event->event_attributes['Premium']))
    $replacement = preg_replace('/\{\/?has_att_premium\}/', '', $match);
    $replacement = '';
    return $replacement;
    add_filter('em_event_output_condition', 'filterEventOutputCondition', 10, 4);

    Then added this to the formatting field:

    <p><span class="hideMe">#_ATT{Premium}</span></p>
    <span class="arrow">More</span>

  11. chocks
    Posted 3 years ago #

    Hey, thanks for posting your solution. Is there a chance to make that conditiona placeholder a php template tag?


    <?php if($event->has_att_premium) :?>
    <?php endif,?>

    thanks again,


  12. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 3 years ago #

    you'd just use this, taken from above:

    if( !empty($EM_Event->event_attributes['Premium'] ) ....

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic