small improvements in handling prof states :

- card date validation now uses direct card duration, not a parameter
- checker for both types of transfert valid and invalid
- mv checks for transfert and date expiration in specific functions
This commit is contained in:
asus
2024-03-21 16:10:07 +01:00
parent 782ae1b1d8
commit 66fbbfd586
7 changed files with 115 additions and 51 deletions

View File

@@ -11,7 +11,6 @@ if (!defined('ABSPATH')) {
/*
* actions after prof form transfert validation is processed
*
@@ -28,29 +27,8 @@ function prof_after_form_transfert_validation_CIPF($form_id, $post_array, $form_
//$user_id = get_current_user_id();
$user_id = $post_array['ID'];
/*
* check if transfert was waiting, if no stop here
* when transfert is validate,
* - change card to valid
* - and reset the field
*
*/
$is_transfert = false;
if (is_account_waiting_valid_CIPF($user_id)) {
$is_transfert = true;
}
else if (is_account_waiting_invalid_CIPF($user_id)) {
$is_transfert = true;
}
if ($is_transfert === false) {
reset_acf_transfert_CIPF($user_id);
return;
}
if (is_transfert_success_CIPF($user_id)) {
set_account_valid_CIPF($user_id);
reset_acf_transfert_CIPF($user_id);
}
// the check is not really connected to the form, it check the acf value, whatever the form value is, the form validation is just a trigger for this check
handle_transfert_validation_CIPF($user_id);
}
add_action('df_after_process', 'prof_after_form_transfert_validation_CIPF', 10, 3);
@@ -72,22 +50,8 @@ function prof_profil_check_CIPF() {
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
/*
* in case event didn't fire, change account to expire here
* also check for waiting transfert : valid -> invalid
*
*/
if (card_date_exists_CIPF($author_id)) {
if (is_card_date_expired_CIPF($author_id)) {
if (!is_account_expired_CIPF($author_id)) {
set_account_expired_CIPF($author_id);
}
if (is_account_waiting_valid_CIPF($author_id)) {
set_account_waiting_invalid_CIPF($author_id);
}
}
}
// in case event didn't fire, handle card_expiration
handle_card_expire_CIPF($author_id);
}
add_action('wp', 'prof_profil_check_CIPF', 11);
@@ -113,7 +77,6 @@ function prof_profil_redirects_CIPF() {
}
/*
* check multiple user roles
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083