Bulk delete old events

Home Forums Calendar Products Events Calendar PRO Bulk delete old events

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1204833
    Dean Spencer
    Participant

    Hi we have been using the Events Calendar Pro for about 3 years, and have thousands of events on our website from 2013, 2014 and 2015.

    I am familiar with phpMyAdmin but am not good with code, joins or syntax.

    We have tried deleting events individually, but the website is crawling and continually crashes. We have also tried the Event Cleanup Plugin but that isn’t visible in Admin and Available Tools when we activate it?

    Can you please tell me the code / syntax to delete all events 4 months old, or older?

    Thank you,

    Dean

    #1205016
    Nico
    Member

    Hi there Dean,

    Thanks for getting in touch with us! Glad to help a long time customer 🙂

    Have you tried using Bulk Delete Plugin? It worked pretty well for me in the past. If this doesn’t help I can give the SQL query a try. In any case be sure to back up the database before the cleanup!

    Cheers,
    Nico

    #1205416
    Dean Spencer
    Participant

    Hi I have tried the Bulk Delete tool which does work, but it only deletes about 20 or 30 events at a time before crashing the server. I then need to restart the server before I can get back into wp-admin.

    I have backed up the database using phpMyAdmin so am able to restore.

    If you could provide an SQL query that would be fantastic. We would like to delete ALL old events, keeping today and future events.

    Thank you!

    #1205528
    Nico
    Member

    Sure Dean,

    I’ve already escalated your request to a developer who will be able to provide the necessary SQL query for the clean up! Will share it with you when ready 🙂

    Best,
    Nico

    #1206025
    Nico
    Member

    Hey Dean,

    I have some news on this! Brook from the support team, commented that deleting the events via MySQL as opposed to using WordPress wp_delete_post function might not be the best. He suggest you run ‘tribe_get_events()’ request, iterate through each id, and do a ‘wp_delete_post()’ on each. You could even wrap this up into a function and have it run on ‘wp_schedule_event()’. Or maybe put a limit on it of 50 events, and run it several times on page load.

    If you decide the go the MySQL way here’s a base SQL query that only needs a ‘WHERE’ clause that searches the ‘postmeta’ table for events with an ‘_EventEndDate’ from four+ months ago:

    https://gist.github.com/elimn/e5de5d2037678de0b926c307022571c5

    Read the comments, it’s crafted to delete recurring events instances not single events, but the modifications should be simple enough. He also mentioned that deleting events this way might lead to orphan recurring child events. Are you just using single events in your site? How many events do you actually have in the site?

    Please let me know if you are able to modify the query to make this work, or if you still need further help on this,
    Best,
    Nico

    #1213799
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Bulk delete old events’ is closed to new replies.