• Resolved samvoyonsdonc

    (@samvoyonsdonc)


    Hey! Sam here
    We’re at 5000 events!
    Can it slow down our website?
    I would love a delete all the ones that are older than a year… but I don’t see how to do this quickly. I can select “events within 12 months” but it seems to be 12 months in the future, not the past.
    Any ideas?
    Thank you so much

Viewing 5 replies - 1 through 5 (of 5 total)
  • joneiseman

    (@joneiseman)

    See the following thread on how to select events in the past: https://www.ads-software.com/support/topic/past-events-not-in-panel/

    Thread Starter samvoyonsdonc

    (@samvoyonsdonc)

    Thank you for your reply.
    I need to keep those of the past year, and delete those form the years before that.
    The way I understand it, the “past event” filter gives all of the events from the past, not just those older than 1 year.

    joneiseman

    (@joneiseman)

    You can sort it by date by clicking on the “Date and Time” heading. Then just select the ones you want to delete.

    Thread Starter samvoyonsdonc

    (@samvoyonsdonc)

    Indeed, I’m aware of this feature as well. But it would take very, very long to sort though 5000 events like this.
    Is there a way to use a different filter?
    Thank you

    joneiseman

    (@joneiseman)

    Make a backup of your database first!

    The following should move events older than 1 year into the Trash (I tried it out and it worked fine on my site).

    $latest = date('Y-m-d', strtotime('-1 year', strtotime('now')));
    $earliest = date('Y-m-d', strtotime('-30 year', strtotime('now')));
    $events = EM_Events::get(['scope' => "$earliest,$latest", 'order' => 'DESC']);
    
    foreach ( $events as $event ) {
        $event->delete();
    }

    You can use the Code Snippets plugin to run this code snippet (choose the “Only run once” option).

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Delete old events?’ is closed to new replies.