wip event schedule

This commit is contained in:
asus
2024-04-02 13:24:22 +02:00
parent 86539d5c14
commit bc06828093
4 changed files with 74 additions and 17 deletions

View File

@@ -52,6 +52,7 @@ include_once(Plgntls::root_path() . 'php/redirections.php');
include_once(Plgntls::root_path() . 'php/display_css.php');
include_once(Plgntls::root_path() . 'php/payments.php');
include_once(Plgntls::root_path() . 'php/random_posts.php');
include_once(Plgntls::root_path() . 'php/scheduled_events.php');
// admin
include_once(Plgntls::root_path() . 'php/admin_hide_bar.php');
include_once(Plgntls::root_path() . 'php/admin_user_profil.php');

View File

@@ -55,8 +55,10 @@ function prof_profil_check_CIPF() {
* in case event didn't fire, handle card changes
*
*/
handle_transfert_validation_CIPF($user_id);
handle_transfert_validation_CIPF($author_id);
handle_card_expire_CIPF($author_id);
schedule_test_CIPF();
}
add_action('wp', 'prof_profil_check_CIPF', 11);

View File

@@ -9,26 +9,80 @@ if (!defined('ABSPATH')) {
/*
* 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 :
*
* - payments : : suppress old order_ids
* - profs : email : validation payment prof, send email
* - profs : email : validation transfert prof, send email
* - partners : : offres temporaires -> gerer qu'elles disparaissent apres la date de validite -> la passer en masquer
* - partners : : 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 ?
* time() + 60 = one minute from now
* time() + MINUTE_IN_SECONDS = one minute from now
* -> https://codex.wordpress.org/Easier_Expression_of_Time_Constants
* -> also strtotime : https://www.php.net/manual/en/function.strtotime.php
*
*/
//function schedule_delete_orderid_CIPF($user_id, $order_id) {
// Plgntls::debug_infos();
// $delay = time() + MINUTE_IN_SECONDS;
// 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', 5, 2);
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);