most account states updating are working

This commit is contained in:
asus
2024-03-19 13:06:16 +01:00
parent 5010b70d79
commit aad98c5188
4 changed files with 153 additions and 89 deletions

View File

@@ -173,6 +173,7 @@ function success_payment_for_user_CIPF($user_id, $order_id) {
set_card_renew_CIPF($user_id);
set_payment_success($user_id);
set_account_valid_CIPF($user_id);
}

View File

@@ -33,8 +33,13 @@ function prof_after_form_CIPF($form_id, $post_array, $form_type) {
/*
* change status to :
* if new prof & paypal : 'to pay'
* if expired card & paypal : 'to_pay'
* if paypal & new prof : 'to pay'
* if paypal & expired card : 'to_pay'
* if transfert $ expired card : 'waiting_invalid'
* if transfert $ valid card : 'waiting_valid'
*
*
*
*
*/
if (is_payment_method_paypal_CIPF()) {
@@ -45,6 +50,14 @@ function prof_after_form_CIPF($form_id, $post_array, $form_type) {
set_account_to_pay_CIPF();
}
}
else if (is_payment_method_transfert_CIPF()) {
if (is_account_expired_CIPF()) {
set_account_waiting_invalid_CIPF();
}
else if (is_account_valid_CIPF()) {
set_account_waiting_valid_CIPF();
}
}
}
add_action('df_after_process', 'prof_after_form_CIPF', 10, 3);
@@ -129,7 +142,7 @@ add_action('template_redirect', 'prof_form_restrictions_CIPF');
/*
* enqueue scripts on page prof
* enqueue scripts and styles on page prof
*
* on the renew card page for prof
* output the right message, depending of the status of the card

View File

@@ -11,46 +11,46 @@ if (!defined('ABSPATH')) {
function handle_prof_is_activ_CIPF($author_id) {
PLGNTLS_class::debug_infos();
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
$slug_wait_activation = PLGNTLS_class::SLUG_PROF_INACTIV;
$acf_id = 'user_' . $author_id;
/*
* if prof is activ, do nothing more
*
*/
$is_activ = get_field($acf_prof_is_activ['_name'], $acf_id);
if ($is_activ === $acf_prof_is_activ['activ'])
return;
/*
* else if prof inactiv
* if is admin or other allowed roles, see the page anyway
* no need to handle allowed roles, it's already
* taken care by author_restriction.php
*
*/
$user_id = get_current_user_id();
if ($user_id !== $author_id)
return;
/*
* if prof is activ
* redirect to waiting page
*
$redirection_prof_inactiv = home_url() . '/' . $slug_wait_activation;
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
wp_redirect($redirection_prof_inactiv, 301);
exit;
*/
}
//function handle_prof_is_activ_CIPF($author_id) {
// PLGNTLS_class::debug_infos();
// $acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
// $slug_wait_activation = PLGNTLS_class::SLUG_PROF_INACTIV;
//
// $acf_id = 'user_' . $author_id;
//
// /*
// * if prof is activ, do nothing more
// *
// */
// $is_activ = get_field($acf_prof_is_activ['_name'], $acf_id);
// if ($is_activ === $acf_prof_is_activ['activ'])
// return;
//
//
// /*
// * else if prof inactiv
// * if is admin or other allowed roles, see the page anyway
// * no need to handle allowed roles, it's already
// * taken care by author_restriction.php
// *
// */
// $user_id = get_current_user_id();
// if ($user_id !== $author_id)
// return;
//
//
// /*
// * if prof is activ
// * redirect to waiting page
// *
// $redirection_prof_inactiv = home_url() . '/' . $slug_wait_activation;
//
// // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
// nocache_headers();
// wp_redirect($redirection_prof_inactiv, 301);
// exit;
// */
//}
/*
@@ -71,45 +71,74 @@ function handle_prof_is_activ_CIPF($author_id) {
* #cipf_prof_paiement_echoue -> on row
*
*/
function show_prof_paiement_messages_CIPF($user_id) {
PLGNTLS_class::debug_infos();
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
$acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
$acf_id = 'user_' . $user_id;
/*
* if prof is inactive, do nothing more
*
*/
$is_activ = get_field($acf_prof_is_activ['_name'], $acf_id);
if (is_null($is_activ))
return;
if (empty($is_activ))
return;
if ($is_activ === $acf_prof_is_activ['activ'])
return;
$cipf_prof_payement = new PLGNTLS_class();
$payement_status = get_field($acf_payment_status['_name'], $acf_id);
if ($payement_status === $acf_payment_status['success']) {
$cipf_prof_payement->add_to_front(array(
array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_reussi {display: block;}' )
));
}
else if ($payement_status === $acf_payment_status['failure']) {
$cipf_prof_payement->add_to_front(array(
array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_echoue {display: block;}' )
));
}
update_field($acf_payment_status['_name'], $acf_payment_status['nothing'], $acf_id);
}
//function show_prof_paiement_messages_CIPF($user_id) {
// PLGNTLS_class::debug_infos();
// $acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
// $acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE;
//
// $acf_id = 'user_' . $user_id;
//
// /*
// * if prof is inactive, do nothing more
// *
// */
// $is_activ = get_field($acf_prof_is_activ['_name'], $acf_id);
// if (is_null($is_activ))
// return;
// if (empty($is_activ))
// return;
// if ($is_activ === $acf_prof_is_activ['activ'])
// return;
//
// $cipf_prof_payement = new PLGNTLS_class();
//
// $payement_status = get_field($acf_payment_status['_name'], $acf_id);
// if ($payement_status === $acf_payment_status['success']) {
// $cipf_prof_payement->add_to_front(array(
// array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_reussi {display: block;}' )
// ));
// }
// else if ($payement_status === $acf_payment_status['failure']) {
// $cipf_prof_payement->add_to_front(array(
// array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_echoue {display: block;}' )
// ));
// }
//
// update_field($acf_payment_status['_name'], $acf_payment_status['nothing'], $acf_id);
//}
/*
* series of check to do before printing a prof author page
* early checks on profil page
*
*/
function check_prof_profil_CIPF() {
PLGNTLS_class::debug_infos();
// is an author page
if (!is_author())
return;
// 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
*
*/
if (is_card_date_expired_CIPF) {
if (!is_account_expired_CIPF) {
set_account_expired_CIPF;
}
}
}
add_action('template_redirect', 'check_prof_page_CIPF', 11);
/*
* if profil needs redirection, it happens here
*
*/
function check_prof_page_CIPF() {
@@ -122,12 +151,33 @@ function check_prof_page_CIPF() {
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
handle_prof_is_activ_CIPF($author_id);
show_prof_paiement_messages_CIPF($author_id);
// redirections here
}
add_action('template_redirect', 'check_prof_page_CIPF', 11);
add_action('template_redirect', 'redirect_prof_page_CIPF', 11);
/*
* time to upload some scripts and styles on prof profil page
*
*/
function check_prof_profil_CIPF() {
PLGNTLS_class::debug_infos();
// is an author page
if (!is_author())
return;
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
$cipf_prof = new PLGNTLS_class();
$cipf_renew->add_to_front();
}
add_action('wp_enqueue_scripts', 'check_prof_page_CIPF', 11);

View File

@@ -11,12 +11,12 @@ if (!defined('ABSPATH')) {
/*
* [/] etat compte ('etat_compte') :
* 1. new . 'nouveau prof' -> ok : [1: a l'inscription - ok]
* 2. to_pay . 'doit payer' -> ko : [1: apres premier form - ok], [2: apres form qui suit carte expiree - ok], [3: apres paiement immediat echoue - ko], [4: apres virement echoue - ko]
* 3. valid . 'carte valide' ->
* 4. waiting_invalid . 'en attente invalide' ->
* 5. waiting_valid . 'en attente valide' ->
* 6. expired . 'carte expiree' ->
* 1. new . 'nouveau prof' -> ok 1/1 : [1: a l'inscription - ok]
* 2. to_pay . 'doit payer' -> ko 3/4 : [1: after form & new - ok], [2: after form choose paypal & expired - ok], [3: after payment failed - ok], [4: after transfert failed - ko]
* 3. valid . 'carte valide' -> ko 1/2 : [1: after payment success - ok], [2: after transfert success - ko]
* 4. waiting_invalid . 'en attente invalide' -> ok 1/1 : [1: after form choose transfert & expired - ok]
* 5. waiting_valid . 'en attente valide' -> ok 1/1 : [1: after form choose transfert & not expired - ok]
* 6. expired . 'carte expiree' -> ko 1/2 : [1: when prof access profil & expired - ok], [2: when event card expired fire - ko]
*
* [/] etat carte ('etat_carte') :
* - 'Commande'