Support

Home Forums Event Espresso Premium People Add-On – only show upcoming events

People Add-On – only show upcoming events

Posted: December 16, 2020 at 9:40 am


echobrin

December 16, 2020 at 9:40 am

For the list of events that appears on a person’s detail page, I’d like to only show upcoming events, not past events. I think I had this working at one point but it looks like my content-espresso_people-details.php might have been based on an old version or something. It’s not sorting correctly and is including some past events. Here’s what I have for content-espresso_people-details.php (I also added the event start date to the list):

<?php
/**
* Template file to add extra content to a single person display
* Note: To customize, just copy the template from /public/templates/* and put in your theme folder.
* @since 1.0.0
* @package EE People Addon
* @subpackage template
* @author Darren Ethier
*/
global $post;

$where = array(
'Person_Post.PER_ID' => $post->ID,
'Person_Post.OBJ_type' => 'Event',
'Datetime.DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))
);
$events = EEM_Event::instance()->get_all(
array(
$where,
'order_by' => array('Datetime.DTT_EVT_start' => 'ASC')
)
);
?>
<div class="eea-people-addon-person-events-container">
<?php if ($events) : ?>
<h3><?php _e('Upcoming classes with this instructor:', 'event_espresso'); ?></h3>
<div class="eea-people-addon-people-type-container">
<ul class="eea-people-addon-event-list-ul">
<?php foreach ($events as $event) : ?>

  • ID()); ?>" title="<?php printf(__('Click here to view more info about %s', 'event_espresso'), $event->name()); ?>"><span class="eea-people-addon-event-name"><?php echo $event->name(); ?> - <?php espresso_event_date('','',$event->ID(), true); ?></span>
  • <?php endforeach; ?>

    </div>
    <?php endif; ?>
    </div>


    Tony

    • Support Staff

    December 17, 2020 at 9:18 am

    When you say ‘some’ expired events, are those events that have the datetime END date after today?

    This where condition:

    'Datetime.DTT_EVT_end' => array(
        '>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))
    );

    Is setting the query to pull Events where the Event END date has not passed yet, if you want only upcoming events use:

    'Datetime.DTT_EVT_start' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))
    );


    echobrin

    December 17, 2020 at 10:49 am

    Ok, that makes sense. With that change I’m still not getting the behavior that I want but I see what it’s doing now. The events have multiple datetimes and it’s showing any event that has an upcoming datetime. I would like to only show events where the FIRST datetime is upcoming. Any event where the first datetime has passed should not be listed at all.

    The support post ‘People Add-On – only show upcoming events’ is closed to new replies.

    Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

    Event Espresso