- most prof states shoud be ok
- redirection partner page creation - user ids on checks states - reset cgv - restrict prof profil page
This commit is contained in:
@@ -10,104 +10,6 @@ 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;
|
||||
// */
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
* check acf field payment_status
|
||||
* if field value is 'success'
|
||||
* - show block 'failure'
|
||||
* - and update field to 'nothing', so it will not show next time
|
||||
* if field value is 'failure'
|
||||
* - show bloc success
|
||||
* - and update field to 'nothing', so it will not show next time
|
||||
* if field value is 'nothing'
|
||||
* - do nothing (keep blocs hidden)
|
||||
* if field value is 'started'
|
||||
* - do nothing (keep blocs hidden)
|
||||
*
|
||||
* .cipf_prof_paiement_message -> on row, added display none in page css
|
||||
* #cipf_prof_paiement_reussi -> on row
|
||||
* #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);
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
* early checks on profil page
|
||||
*
|
||||
@@ -128,13 +30,13 @@ function prof_profil_check_CIPF() {
|
||||
* also check for waiting transfert : valid -> invalid
|
||||
*
|
||||
*/
|
||||
if (card_date_exists_CIPF()) {
|
||||
if (is_card_date_expired_CIPF()) {
|
||||
if (!is_account_expired_CIPF()) {
|
||||
set_account_expired_CIPF();
|
||||
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()) {
|
||||
set_account_waiting_invalid_CIPF();
|
||||
if (is_account_waiting_valid_CIPF($author_id)) {
|
||||
set_account_waiting_invalid_CIPF($author_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,6 +52,8 @@ add_action('wp', 'prof_profil_check_CIPF', 11);
|
||||
*/
|
||||
function prof_profil_redirects_CIPF() {
|
||||
PLGNTLS_class::debug_infos();
|
||||
$role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||
|
||||
// is an author page
|
||||
if (!is_author())
|
||||
@@ -158,7 +62,35 @@ function prof_profil_redirects_CIPF() {
|
||||
// the way to find the id of the author of an author_page
|
||||
$author_id = get_queried_object_id();
|
||||
|
||||
// redirections here
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
/*
|
||||
* check multiple user roles
|
||||
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
|
||||
* if user->role is found in array of allowed role, no redirection needed
|
||||
*
|
||||
*/
|
||||
$allowed_roles = array($role_admin, $role_fipf);
|
||||
if (array_intersect($allowed_roles, $current_user->roles))
|
||||
return;
|
||||
|
||||
/*
|
||||
* both 'get_queried_object_id' and 'get_the_author_meta' works here,
|
||||
* i don't knwo why it's not alwasy the case :
|
||||
*
|
||||
$author_id = get_the_author_meta( 'ID' );
|
||||
*/
|
||||
$author_id = get_queried_object_id();
|
||||
|
||||
$current_user_id = get_current_user_id();
|
||||
|
||||
/*
|
||||
* if connected user is not author, get out
|
||||
*
|
||||
*/
|
||||
if ($current_user_id != $author_id) {
|
||||
redirection_profil_CIPF();
|
||||
}
|
||||
|
||||
}
|
||||
add_action('template_redirect', 'prof_profil_redirects_CIPF', 11);
|
||||
|
||||
Reference in New Issue
Block a user