created functions to handle all state changes

This commit is contained in:
asus
2024-03-19 12:37:16 +01:00
parent f221e43807
commit 5010b70d79
7 changed files with 317 additions and 97 deletions

View File

@@ -15,7 +15,7 @@ if (!defined('ABSPATH')) {
* actions after prof form is validated
*
*/
function prof_form_reset_fields_CIPF($form_id, $post_array, $form_type) {
function prof_after_form_CIPF($form_id, $post_array, $form_type) {
PLGNTLS_class::debug_infos();
$acf_cgv = PLGNTLS_class::ACF_PROF_CGV;
$acf_account_state = PLGNTLS_class::ACF_ACCOUNT_STATE;
@@ -32,15 +32,21 @@ function prof_form_reset_fields_CIPF($form_id, $post_array, $form_type) {
/*
* if new prof, change status to 'to pay'
* change status to :
* if new prof & paypal : 'to pay'
* if expired card & paypal : 'to_pay'
*
*/
$is_new = get_field($acf_account_state['_name'], $acf_id);
if ($is_new === $acf_account_state['new']) {
update_field($acf_account_state['_name'], $acf_account_state['to_pay'], $acf_id);
if (is_payment_method_paypal_CIPF()) {
if (is_account_new_CIPF()) {
set_account_to_pay_CIPF();
}
if (is_account_expired_CIPF()) {
set_account_to_pay_CIPF();
}
}
}
add_action('df_after_process', 'prof_form_reset_fields_CIPF', 10, 3);
add_action('df_after_process', 'prof_after_form_CIPF', 10, 3);