From 215d778307712fe1583887c4b183af5019e66484 Mon Sep 17 00:00:00 2001 From: asus Date: Tue, 9 Apr 2024 23:20:35 +0200 Subject: [PATCH] event deletion account reminder --- .../php/_actions_scheduled_events.php | 29 +++++++++++++------ .../php/paypal/update_user_payment.php | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/plugins/cipf_plugin/php/_actions_scheduled_events.php b/plugins/cipf_plugin/php/_actions_scheduled_events.php index 6374158..2134bdf 100644 --- a/plugins/cipf_plugin/php/_actions_scheduled_events.php +++ b/plugins/cipf_plugin/php/_actions_scheduled_events.php @@ -146,16 +146,27 @@ add_action('CIPF_reminder_before_card_expire', 'send_emails_CIPF', 10, 2); /* * 6. && 7. prof, send email reminder account deletion * -function schedule__CIPF($user_id) { - Plgntls::debug_infos(); - $delay = strtotime('+3 days'); - wp_schedule_single_event($delay, 'scedule_event_CIPF', array($user_id)); -} -function event_CIPF($user_id) { - Plgntls::debug_infos(); -} -add_action('schedule_event_CIPF', 'event_CIPF', 10, 2); */ +function schedule_reminder_before_account_delete_CIPF($user_id) { + Plgntls::debug_infos(); + $account_reminder_1 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_DELETE_FIRST; + $account_reminder_2 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_DELETE_LAST; + $duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE; + + $date_limit = get_card_date_expiration_CIPF($user_id); + if (false === $date_limit) { + return; + } + + $new_date = $date_limit->modify($duration_deletion); + $new_date_1 = $new_date->modify($account_reminder_1); + $new_date_2 = $new_date->modify($account_reminder_2); + $delay_1 = $new_date_1->getTimestamp(); + $delay_2 = $new_date_2->getTimestamp(); + wp_schedule_single_event($delay_1, 'CIPF_reminder_before_account_delete', array('account_will_be_deleted', $user_id)); + wp_schedule_single_event($delay_2, 'CIPF_reminder_before_account_delete', array('account_will_be_deleted', $user_id)); +} +add_action('CIPF_reminder_before_account_delete', 'send_emails_CIPF', 10, 2); diff --git a/plugins/cipf_plugin/php/paypal/update_user_payment.php b/plugins/cipf_plugin/php/paypal/update_user_payment.php index c80cda3..1aad15c 100644 --- a/plugins/cipf_plugin/php/paypal/update_user_payment.php +++ b/plugins/cipf_plugin/php/paypal/update_user_payment.php @@ -177,6 +177,7 @@ function success_payment_for_user_CIPF($user_id, $order_id) { schedule_deactivate_expired_card_CIPF($user_id); schedule_prof_account_deletion_CIPF($user_id); schedule_reminder_before_card_expire_CIPF($user_id); + schedule_reminder_before_account_delete_CIPF($user_id); if (is_card_new_CIPF($user_id)) { set_card_number_CIPF($user_id);