PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Any code snippets to set a day range to auto clear old history?

This support system is for all types of the plugins as for premium versions, so for free ones! If you have premium version do not forget in the private data of the request (!!not in the text of the support request!!) after its publishing insert purchase code please (see blue-green button on the right side) and press Save button.
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi

Any code snippets to set a day range to auto clear old history for all users? e.g. delete history older than 30 days.

Million thanks

Hello

It is possible with MySQL and using external cron. You can use next code for your cron action:

global $wpdb;
$time = time()-30*24*60*60;
$wpdb->query("DELETE FROM woobe_history_bulk WHERE mod_date<{$time}");
$wpdb->query("DELETE FROM wp_woobe_history_bulk WHERE finished<{$time}");

 

 

Hi,

I have add below code in function.php and set the timer to 1 minute to test by using WP Control cron job BUT seems failed and nothing happen and no history clear.

add_action( 'test_new_cron', 'delete_old_woobe_hisroty_func' );
function delete_old_woobe_hisroty_func() {
global $wpdb;
$time = time()-60;
$wpdb->query("DELETE FROM woobe_history_bulk WHERE mod_date<{$time}");
$wpdb->query("DELETE FROM wp_woobe_history_bulk WHERE finished<{$time}");
}

https://wordpress.org/plugins/wp-crontrol/

Would you please help to guide me how to setup the cron job for auto clear history over specific time?

Million thanks

Hello

You can use external cron:

 

Hi,

I have added below code in function.php to test delete history over 1 day

function delete_old_woobe_hisroty_func() {
global $wpdb;
$time = time()-1*24*60*60;
$wpdb->query("DELETE FROM woobe_history_bulk WHERE mod_date<{$time}");
$wpdb->query("DELETE FROM wp_woobe_history_bulk WHERE finished<{$time}");
}

if(isset($_GET['delete_old_woobe_hisroty_func'])){
delete_old_woobe_hisroty_func();
exit;
}

and then I tried to visit https://mydomain.com/?delete_old_woobe_hisroty_func=1 in browser manually, however, still not work, no record deleted.

Please help

and hope you will consider to add feature that can set auto clear old history over specific time/days.

Many thanks

Hello

What plugin version number are you using?

Code Snippets Version 2.14.1
https://wordpress.org/plugins/code-snippets/
and
WP Crontrol Version 1.10.0
https://wordpress.org/plugins/wp-crontrol/

WordPress 5.8
WooCommerce 5.6.0

Million thanks

Sory!  I  mean  version  of  BEAR/WOOBE plugin

BEAR - Bulk Editor and Products Manager Version 2.0.8.1

Thanks :)

Hello

Ok!  Please paste your license key here - https://share.stackovergo.com/image/i20210618130558.png -> https://share.stackovergo.com/image/i20210618130614.png and  wp-admin+FTP access - https://share.stackovergo.com/image/i20210618130637.png I will  check  this snippet