|
|
|
|
@@ -81,19 +81,19 @@ add_action('CIPF_orderid_deletion_event', 'delete_order_id_later_CIPF', 10, 2);
|
|
|
|
|
* need to include file for wp_delete_user to work : https://developer.wordpress.org/reference/functions/wp_delete_user/
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function schedule_prof_account_deletion_CIPF($user_id) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
$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);
|
|
|
|
|
$delay = $new_date->getTimestamp();
|
|
|
|
|
wp_schedule_single_event($delay, 'CIPF_prof_account_deletion', array($user_id));
|
|
|
|
|
}
|
|
|
|
|
add_action('CIPF_prof_account_deletion', 'handle_prof_account_deletion_CIPF');
|
|
|
|
|
//function schedule_prof_account_deletion_CIPF($user_id) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
// $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);
|
|
|
|
|
// $delay = $new_date->getTimestamp();
|
|
|
|
|
// wp_schedule_single_event($delay, 'CIPF_prof_account_deletion', array($user_id));
|
|
|
|
|
//}
|
|
|
|
|
//add_action('CIPF_prof_account_deletion', 'handle_prof_account_deletion_CIPF');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -102,18 +102,18 @@ add_action('CIPF_prof_account_deletion', 'handle_prof_account_deletion_CIPF');
|
|
|
|
|
* 3. prof, deactivate card at expiration time, also email
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function schedule_deactivate_expired_card_CIPF($user_id) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
|
|
|
|
|
$date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
if (false === $date_limit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$new_date = $date_limit->modify('+1 day');
|
|
|
|
|
$delay = $new_date->getTimestamp();
|
|
|
|
|
wp_schedule_single_event($delay, 'CIPF_deactivate_expired_card', array($user_id));
|
|
|
|
|
}
|
|
|
|
|
add_action('CIPF_deactivate_expired_card', 'handle_card_expire_CIPF');
|
|
|
|
|
//function schedule_deactivate_expired_card_CIPF($user_id) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
//
|
|
|
|
|
// $date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
// if (false === $date_limit) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// $new_date = $date_limit->modify('+1 day');
|
|
|
|
|
// $delay = $new_date->getTimestamp();
|
|
|
|
|
// wp_schedule_single_event($delay, 'CIPF_deactivate_expired_card', array($user_id));
|
|
|
|
|
//}
|
|
|
|
|
//add_action('CIPF_deactivate_expired_card', 'handle_card_expire_CIPF');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -122,50 +122,50 @@ add_action('CIPF_deactivate_expired_card', 'handle_card_expire_CIPF');
|
|
|
|
|
* 4. && 5. prof, send email reminder before account expire
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function schedule_reminder_before_card_expire_CIPF($user_id) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
$card_reminder_1 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_FIRST;
|
|
|
|
|
$card_reminder_2 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_LAST;
|
|
|
|
|
|
|
|
|
|
$date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
if (false === $date_limit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$new_date_1 = $date_limit->modify($card_reminder_1);
|
|
|
|
|
$new_date_2 = $date_limit->modify($card_reminder_2);
|
|
|
|
|
$delay_1 = $new_date_1->getTimestamp();
|
|
|
|
|
$delay_2 = $new_date_2->getTimestamp();
|
|
|
|
|
wp_schedule_single_event($delay_1, 'CIPF_reminder_before_card_expire', array($user_id, $card_reminder_1));
|
|
|
|
|
wp_schedule_single_event($delay_2, 'CIPF_reminder_before_card_expire', array($user_id, $card_reminder_2));
|
|
|
|
|
}
|
|
|
|
|
function send_emails_reminder_before_card_expire_CIPF($user_id, $duration) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
|
|
|
|
|
if (!isset_acf_card_expiration_CIPF($user_id)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (is_card_date_expired_CIPF($user_id)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
if (false === $date_limit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$date_reminder = $date_limit->modify($duration);
|
|
|
|
|
$date_diff = date_diff($date_limit, $date_reminder);
|
|
|
|
|
$date_diff = (int)$date_diff->format('%R%a');
|
|
|
|
|
|
|
|
|
|
$date_now = date_create('now');
|
|
|
|
|
$current_date_diff = date_diff($date_limit, $date_now);
|
|
|
|
|
$current_date_diff = (int)$current_date_diff->format('%R%a');
|
|
|
|
|
|
|
|
|
|
// i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
|
|
|
|
|
if (abs($current_date_diff) <= (abs($date_diff + 3))) {
|
|
|
|
|
send_emails_CIPF('card_will_expire', $user_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
add_action('CIPF_reminder_before_card_expire', 'send_emails_reminder_before_card_expire_CIPF', 10, 2);
|
|
|
|
|
//function schedule_reminder_before_card_expire_CIPF($user_id) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
// $card_reminder_1 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_FIRST;
|
|
|
|
|
// $card_reminder_2 = Cipf::DURATION_REMINDER_BEFORE_ACCOUNT_EXPIRE_LAST;
|
|
|
|
|
//
|
|
|
|
|
// $date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
// if (false === $date_limit) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// $new_date_1 = $date_limit->modify($card_reminder_1);
|
|
|
|
|
// $new_date_2 = $date_limit->modify($card_reminder_2);
|
|
|
|
|
// $delay_1 = $new_date_1->getTimestamp();
|
|
|
|
|
// $delay_2 = $new_date_2->getTimestamp();
|
|
|
|
|
// wp_schedule_single_event($delay_1, 'CIPF_reminder_before_card_expire', array($user_id, $card_reminder_1));
|
|
|
|
|
// wp_schedule_single_event($delay_2, 'CIPF_reminder_before_card_expire', array($user_id, $card_reminder_2));
|
|
|
|
|
//}
|
|
|
|
|
//function send_emails_reminder_before_card_expire_CIPF($user_id, $duration) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
//
|
|
|
|
|
// if (!isset_acf_card_expiration_CIPF($user_id)) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// if (is_card_date_expired_CIPF($user_id)) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// $date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
// if (false === $date_limit) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $date_reminder = $date_limit->modify($duration);
|
|
|
|
|
// $date_diff = date_diff($date_limit, $date_reminder);
|
|
|
|
|
// $date_diff = (int)$date_diff->format('%R%a');
|
|
|
|
|
//
|
|
|
|
|
// $date_now = date_create('now');
|
|
|
|
|
// $current_date_diff = date_diff($date_limit, $date_now);
|
|
|
|
|
// $current_date_diff = (int)$current_date_diff->format('%R%a');
|
|
|
|
|
//
|
|
|
|
|
// // i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
|
|
|
|
|
// if (abs($current_date_diff) <= (abs($date_diff + 3))) {
|
|
|
|
|
// send_emails_CIPF('card_will_expire', $user_id);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//add_action('CIPF_reminder_before_card_expire', 'send_emails_reminder_before_card_expire_CIPF', 10, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -174,55 +174,55 @@ add_action('CIPF_reminder_before_card_expire', 'send_emails_reminder_before_card
|
|
|
|
|
* 6. && 7. prof, send email reminder account deletion
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$date_deletion = $date_limit->modify($duration_deletion);
|
|
|
|
|
$new_date_1 = $date_deletion->modify($account_reminder_1);
|
|
|
|
|
$new_date_2 = $date_deletion->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($user_id, $account_reminder_1));
|
|
|
|
|
wp_schedule_single_event($delay_2, 'CIPF_reminder_before_account_delete', array($user_id, $account_reminder_2));
|
|
|
|
|
}
|
|
|
|
|
function send_emails_reminder_before_account_delete_CIPF($user_id, $duration) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
$duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
|
|
|
|
|
|
|
|
|
|
if (!isset_acf_card_expiration_CIPF($user_id)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!is_card_date_expired_CIPF($user_id)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
if (false === $date_limit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$date_deletion = $date_limit->modify($duration_deletion);
|
|
|
|
|
$date_reminder = $date_deletion->modify($duration);
|
|
|
|
|
$date_diff = date_diff($date_deletion, $date_reminder);
|
|
|
|
|
$date_diff = (int)$date_diff->format('%R%a');
|
|
|
|
|
|
|
|
|
|
$date_now = date_create('now');
|
|
|
|
|
$current_date_diff = date_diff($date_deletion, $date_now);
|
|
|
|
|
$current_date_diff = (int)$current_date_diff->format('%R%a');
|
|
|
|
|
|
|
|
|
|
// i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
|
|
|
|
|
if (abs($current_date_diff) <= (abs($date_diff + 3))) {
|
|
|
|
|
send_emails_CIPF('account_will_be_deleted', $user_id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
add_action('CIPF_reminder_before_account_delete', 'send_emails_reminder_before_account_delete_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;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $date_deletion = $date_limit->modify($duration_deletion);
|
|
|
|
|
// $new_date_1 = $date_deletion->modify($account_reminder_1);
|
|
|
|
|
// $new_date_2 = $date_deletion->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($user_id, $account_reminder_1));
|
|
|
|
|
// wp_schedule_single_event($delay_2, 'CIPF_reminder_before_account_delete', array($user_id, $account_reminder_2));
|
|
|
|
|
//}
|
|
|
|
|
//function send_emails_reminder_before_account_delete_CIPF($user_id, $duration) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
// $duration_deletion = Cipf::DURATION_ACCOUNT_DELETE_AFTER_EXPIRE;
|
|
|
|
|
//
|
|
|
|
|
// if (!isset_acf_card_expiration_CIPF($user_id)) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// if (!is_card_date_expired_CIPF($user_id)) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// $date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
// if (false === $date_limit) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $date_deletion = $date_limit->modify($duration_deletion);
|
|
|
|
|
// $date_reminder = $date_deletion->modify($duration);
|
|
|
|
|
// $date_diff = date_diff($date_deletion, $date_reminder);
|
|
|
|
|
// $date_diff = (int)$date_diff->format('%R%a');
|
|
|
|
|
//
|
|
|
|
|
// $date_now = date_create('now');
|
|
|
|
|
// $current_date_diff = date_diff($date_deletion, $date_now);
|
|
|
|
|
// $current_date_diff = (int)$current_date_diff->format('%R%a');
|
|
|
|
|
//
|
|
|
|
|
// // i add +3 in case there is a difference of maximum 3 days between a 31 days month and a 28 days february
|
|
|
|
|
// if (abs($current_date_diff) <= (abs($date_diff + 3))) {
|
|
|
|
|
// send_emails_CIPF('account_will_be_deleted', $user_id);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
//add_action('CIPF_reminder_before_account_delete', 'send_emails_reminder_before_account_delete_CIPF', 10, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -231,31 +231,31 @@ add_action('CIPF_reminder_before_account_delete', 'send_emails_reminder_before_a
|
|
|
|
|
* 8. partner, send email before offer expire
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function schedule_partner_before_offer_expire_CIPF($user_id) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
$offer_expire = Cipf::DURATION_REMINDER_BEFORE_OFFER_EXPIRE;
|
|
|
|
|
|
|
|
|
|
// error_log("is_offer_1: " . json_encode(is_activ_partner_offer_1_date_CIPF($post_id)));
|
|
|
|
|
// error_log("offer_1 date: " . json_encode(get_partner_offer_1_date_CIPF($post_id)));
|
|
|
|
|
// error_log("is_offer_2: " . json_encode(is_activ_partner_offer_2_date_CIPF($post_id)));
|
|
|
|
|
// error_log("offer_2 date: " . json_encode(get_partner_offer_2_date_CIPF($post_id)));
|
|
|
|
|
// error_log("is_offer_3: " . json_encode(is_activ_partner_offer_3_date_CIPF($post_id)));
|
|
|
|
|
// error_log("offer_3 date: " . json_encode(get_partner_offer_3_date_CIPF($post_id)));
|
|
|
|
|
// $date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
if (false === $date_limit) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$new_date = $date_limit->modify($offer_expire);
|
|
|
|
|
$delay = $new_date->getTimestamp();
|
|
|
|
|
wp_schedule_single_event($delay, 'CIPF_partner_before_offer_expire', array($user_id));
|
|
|
|
|
}
|
|
|
|
|
function send_emails_reminder_before_offer_expire_CIPF($user_id) {
|
|
|
|
|
Plgntls::debug_infos();
|
|
|
|
|
|
|
|
|
|
send_emails_CIPF('offer_will_expire', $user_id);
|
|
|
|
|
}
|
|
|
|
|
add_action('CIPF_partner_before_offer_expire', 'send_emails_reminder_before_offer_expire_CIPF');
|
|
|
|
|
//function schedule_partner_before_offer_expire_CIPF($user_id) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
// $offer_expire = Cipf::DURATION_REMINDER_BEFORE_OFFER_EXPIRE;
|
|
|
|
|
//
|
|
|
|
|
//// error_log("is_offer_1: " . json_encode(is_activ_partner_offer_1_date_CIPF($post_id)));
|
|
|
|
|
//// error_log("offer_1 date: " . json_encode(get_partner_offer_1_date_CIPF($post_id)));
|
|
|
|
|
//// error_log("is_offer_2: " . json_encode(is_activ_partner_offer_2_date_CIPF($post_id)));
|
|
|
|
|
//// error_log("offer_2 date: " . json_encode(get_partner_offer_2_date_CIPF($post_id)));
|
|
|
|
|
//// error_log("is_offer_3: " . json_encode(is_activ_partner_offer_3_date_CIPF($post_id)));
|
|
|
|
|
//// error_log("offer_3 date: " . json_encode(get_partner_offer_3_date_CIPF($post_id)));
|
|
|
|
|
//// $date_limit = get_card_date_expiration_CIPF($user_id);
|
|
|
|
|
// if (false === $date_limit) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $new_date = $date_limit->modify($offer_expire);
|
|
|
|
|
// $delay = $new_date->getTimestamp();
|
|
|
|
|
// wp_schedule_single_event($delay, 'CIPF_partner_before_offer_expire', array($user_id));
|
|
|
|
|
//}
|
|
|
|
|
//function send_emails_reminder_before_offer_expire_CIPF($user_id) {
|
|
|
|
|
// Plgntls::debug_infos();
|
|
|
|
|
//
|
|
|
|
|
// send_emails_CIPF('offer_will_expire', $user_id);
|
|
|
|
|
//}
|
|
|
|
|
//add_action('CIPF_partner_before_offer_expire', 'send_emails_reminder_before_offer_expire_CIPF');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|