Files
2024_WEBSITE_fipf/plugins/cipf_plugin/php/scheduled_events.php
2024-04-03 15:16:00 +02:00

94 lines
1.9 KiB
PHP

<?php
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* schedule events :
* - first use a function to add the event :
* - function launch_schedule_my_evet() {
* wp_schedule_single_event($delay, 'hook_event_name');
* }
* - this will enqueue an action hook when the time will come, that you must define :
* - add_action('hook_event_name', 'callback_function');
* - and finally, define the function 'callback_function()'
*
* to define the delay, you can use the strtotime notation
* - strtotime('+1 month');
* -> https://www.php.net/manual/en/function.strtotime.php
* or the time constants in seconds :
* - time() + 3 * MINUTE_IN_SECONDS
* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants
*
*/
/*
* events and emails :
*
* - payments : : suppress old order_ids
* - partners : email : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
* - partners : email : la gestion des offres à échéance
* - payments : email : schedule event pour supprimer le compte xx temps (6 mois ?) apres fin de validite de la carte
* - payments : email : schedule event pour supprimer les codes
* - payments : email : schedule event pour desactiver la carte
* - payments : email : faire rappels emails
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
/*
* add a schedule event to delete this order_id
* after 3 days ?
*
*/
function schedule_delete_orderid_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
$delay = strtotime('+3 days');
wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', array($user_id, $order_id));
}
function delete_order_id_later_CIPF($user_id, $order_id) {
Plgntls::debug_infos();
delete_user_meta($user_id, 'cipf_order_id', $order_id);
}
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 10, 2);
?>