Delete Database Once a Day

[ad_1]

Thread Starter
jeng22

(@jeng22)

Figured something out using CRON jobs. Here’s how I did it for those who want the same setup 🙂

1. in your functions.php –

/* CONTACT FORM DUPLICATE ENTRIES CRON JOB */
function delete_all_duplicate_killer_data() {
    global $wpdb;
    $dkdb = apply_filters('duplicate_killer_database', $wpdb);
    $table_name = $dkdb->prefix . 'dk_forms_duplicate';

    // Delete all records from the database table
    $dkdb->query("TRUNCATE TABLE $table_name");
}

// Hook the function to a custom action hook
add_action('delete_all_duplicate_killer_data_hook', 'delete_all_duplicate_killer_data');

2. Install “WP Crontrol” and then add new Cron event with the following values –
Hook name: delete_all_duplicate_killer_data_hook
arguments: leave blank
Next run: up to you. But I did “At this time:” with 12am and “Once Daily” recurrence.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer