schedult card expiration

This commit is contained in:
asus
2024-04-09 22:33:34 +02:00
parent 364553612a
commit a2e37cf621
4 changed files with 53 additions and 42 deletions

View File

@@ -97,7 +97,6 @@ function is_paypal_force_1_cent_CIPF() {
Plgntls::debug_infos();
$paypal_options = get_paypal_options_CIPF();
error_log("paypal_options: " . json_encode($paypal_options));
return $paypal_options['force_1_cent'];
}

View File

@@ -58,7 +58,7 @@ function schedule_delete_orderid_CIPF($order_id, $user_id) {
$duration_order_id = Cipf::DURATION_OLD_ORDER_ID;
$delay = strtotime($duration_order_id);
wp_schedule_single_event($delay, 'orderid_deletion_event_CIPF', array($order_id, $user_id));
wp_schedule_single_event($delay, 'CIPF_orderid_deletion_event', array($order_id, $user_id));
}
function delete_order_id_later_CIPF($order_id, $user_id) {
Plgntls::debug_infos();
@@ -71,7 +71,7 @@ function delete_order_id_later_CIPF($order_id, $user_id) {
}
reset_acf_order_id_CIPF($user_id);
}
add_action('orderid_deletion_event_CIPF', 'delete_order_id_later_CIPF', 10, 2);
add_action('CIPF_orderid_deletion_event', 'delete_order_id_later_CIPF', 10, 2);
@@ -91,37 +91,9 @@ function schedule_prof_account_deletion_CIPF($user_id) {
}
$date_limit->modify($duration_deletion);
$delay = $date_limit->getTimestamp();
wp_schedule_single_event($delay, 'schedule_event_prof_account_deletion_CIPF', array($user_id));
wp_schedule_single_event($delay, 'CIPF_schedule_event_prof_account_deletion', array($user_id));
}
/*
* this function will delete the account if the deletion date is expired
* it is called both by e scheduled event, and every time a prof go on its page
*
*/
function handle_prof_account_deletion_CIPF($user_id) {
Plgntls::debug_infos();
/*
* check if account still exists
*
*/
if (false === get_user_by('id', $user_id)) {
return;
}
/*
* check if account should be deleted
*
*/
if (!is_prof_account_deletion_date_exceeded_CIPF($user_id)) {
return;
}
send_emails_CIPF('account_deleted', $user_id);
include_once(ABSPATH.'wp-admin/includes/user.php');
wp_delete_user($user_id);
}
add_action('schedule_event_prof_account_deletion_CIPF', 'handle_prof_account_deletion_CIPF');
add_action('CIPF_schedule_event_prof_account_deletion', 'handle_prof_account_deletion_CIPF');
@@ -129,16 +101,20 @@ add_action('schedule_event_prof_account_deletion_CIPF', 'handle_prof_account_del
/*
* 3. prof, deactivate card at expiration time, also email
*
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_deactivate_expired_card_CIPF($user_id) {
Plgntls::debug_infos();
$duration_validity = Cipf::DURATION_CARD_VALIDITY;
$date_limit = get_card_date_expiration_CIPF($user_id);
if (false === $date_limit) {
return;
}
$date_limit->modify('+1 day');
$delay = $date_limit->getTimestamp();
wp_schedule_single_event($delay, 'CIPF_schedule_event_deactivate_expired_card', array($user_id));
}
add_action('CIPF_schedule_event_deactivate_expired_card', 'handle_card_expire_CIPF');

View File

@@ -169,9 +169,13 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
/*
* else
* order is important for some
* -> first update date, then schedul events
*
*/
update_card_date_expiration_CIPF($user_id);
schedule_deactivate_expired_card_CIPF($user_id);
schedule_prof_account_deletion_CIPF($user_id);
if (is_card_new_CIPF($user_id)) {
set_card_number_CIPF($user_id);

View File

@@ -85,4 +85,36 @@ function handle_card_expire_CIPF($user_id) {
/*
* this function will delete the account if the deletion date is expired
* it is called both by e scheduled event, and every time a prof go on its page
*
*/
function handle_prof_account_deletion_CIPF($user_id) {
Plgntls::debug_infos();
/*
* check if account still exists
*
*/
if (false === get_user_by('id', $user_id)) {
return;
}
/*
* check if account should be deleted
*
*/
if (!is_prof_account_deletion_date_exceeded_CIPF($user_id)) {
return;
}
send_emails_CIPF('account_deleted', $user_id);
include_once(ABSPATH.'wp-admin/includes/user.php');
wp_delete_user($user_id);
}
?>