Title: Remove events after date
Last modified: February 4, 2021

---

# Remove events after date

 *  [looije](https://wordpress.org/support/users/looije/)
 * (@looije)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/remove-events-after-date/)
 * We have hundreds of events per month in our calendar, and I would like for them
   to become unpublished or removed after their date has pass. I know you can remove
   the link, but the link is not currently being used, but rather custom code so
   it reflects our branding on the site.

Viewing 1 replies (of 1 total)

 *  Plugin Author [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * (@joedolson)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/remove-events-after-date/#post-14009224)
 * I’ve added a filter that runs when fetching events that would allow you to write
   custom code to delete or otherwise modify events after they’re over. It’ll be
   in the next released version.
 * The filter is `mc_event_object` and is run after an event is fetched from the
   database for display and the object is instantiated. At that time, you can write
   code to inspect the event to see if it has ended and execute whatever custom 
   code you need to. E.g.
 *     ```
       function delete_my_events( $event ) {
            $end_date = strtotime( $event->occur_end );
            if ( $end_date < time() ) {
                 mc_delete_event( $event->event_id );
   
                 return false;
            }
   
            return $event;
       }
       add_filter( 'mc_event_object', 'delete_my_events', 10, 1 );
       ```
   
 * (Warning: the above is *not* tested.)

Viewing 1 replies (of 1 total)

The topic ‘Remove events after date’ is closed to new replies.

 * ![](https://ps.w.org/my-calendar/assets/icon-256x256.png?rev=1097576)
 * [My Calendar - Accessible Event Manager](https://wordpress.org/plugins/my-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/my-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/my-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/my-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/my-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/my-calendar/reviews/)

## Tags

 * [events](https://wordpress.org/support/topic-tag/events/)

 * 1 reply
 * 2 participants
 * Last reply from: [Joe Dolson](https://wordpress.org/support/users/joedolson/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/remove-events-after-date/#post-14009224)
 * Status: not resolved