added dates functions for prof card

This commit is contained in:
asus
2024-03-19 08:58:59 +01:00
parent 5e7ca4f0f1
commit f221e43807
4 changed files with 196 additions and 86 deletions

View File

@@ -12,9 +12,7 @@ if (!defined('ABSPATH')) {
/*
* when form is validated
* - reset some fields
* - change account state
* actions after prof form is validated
*
*/
function prof_form_reset_fields_CIPF($form_id, $post_array, $form_type) {
@@ -25,10 +23,23 @@ function prof_form_reset_fields_CIPF($form_id, $post_array, $form_type) {
$user_id = get_current_user_id();
$acf_id = 'user_'.$user_id;
/*
* reset cgv
*
*/
update_field($acf_cgv['_name'], array(""), $acf_id);
update_field($acf_account_state['_name'], $acf_account_state['to_pay'], $acf_id);
/*
* if new prof, change status to '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);
}
}
//add_action('df_before_process', 'prof_form_reset_fields_CIPF', 10, 3);
add_action('df_after_process', 'prof_form_reset_fields_CIPF', 10, 3);
@@ -36,44 +47,6 @@ add_action('df_after_process', 'prof_form_reset_fields_CIPF', 10, 3);
/*
*
* NOT USEFUL ANYMORE :
* it was to fix pbms in formbuilder with calculation field
* but I made 2 better fixes (css and js)
*
* reset some fields for the form to buy the card
* - cgv
* - paiement
* - livraison
* - tarif
* this action is called after redirection hook
*
*/
//function reset_some_fields_CIPF() {
// PLGNTLS_class::debug_infos();
// $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
// $acf_cgv = PLGNTLS_class::ACF_PROF_CGV;
// $acf_payement = PLGNTLS_class::ACF_CARD_PAYMENT_METHOD;
// $acf_delivery = PLGNTLS_class::ACF_CARD_PRICE_DELIVERY;
// $acf_price = PLGNTLS_class::ACF_CARD_PRICE_CHOICE;
//
// if (!is_page($slug_renew_card))
// return;
//
// $user_id = get_current_user_id();
// update_field($acf_cgv['_name'] , array(""), 'user_'.$user_id);
// update_field($acf_payement['_name'], array(""), 'user_'.$user_id);
// update_field($acf_delivery['_name'], array(""), 'user_'.$user_id);
// update_field($acf_price['_name'] , array(""), 'user_'.$user_id);
//}
//add_action('wp', 'reset_some_fields_CIPF');
/*
* on renew page :
* - check restrictions
@@ -85,7 +58,7 @@ add_action('df_after_process', 'prof_form_reset_fields_CIPF', 10, 3);
* - except admins and editor
*
*/
function renew_page_restrictions_CIPF(){
function prof_form_restrictions_CIPF(){
PLGNTLS_class::debug_infos();
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
@@ -142,7 +115,7 @@ function renew_page_restrictions_CIPF(){
}
*/
}
add_action('template_redirect', 'renew_page_restrictions_CIPF');
add_action('template_redirect', 'prof_form_restrictions_CIPF');
@@ -150,6 +123,8 @@ add_action('template_redirect', 'renew_page_restrictions_CIPF');
/*
* enqueue scripts on page prof
*
* on the renew card page for prof
* output the right message, depending of the status of the card
* 'renouveler' or 'commander'