73 lines
1.3 KiB
PHP
73 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* it means someone outside wp is accessing the file, in this case kill it.
|
|
*/
|
|
if (!defined('ABSPATH')) {
|
|
die('You can not access this file!');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handle_prof_is_activ_CIPF($author_id) {
|
|
$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, $acf_id);
|
|
if ($is_activ === 'Actif')
|
|
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;
|
|
|
|
wp_redirect($redirection_prof_inactiv);
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* series of check to do before printing a prof author page
|
|
*
|
|
*/
|
|
function check_prof_page_CIPF() {
|
|
// 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();
|
|
|
|
handle_prof_is_activ_CIPF($author_id);
|
|
}
|
|
add_action('template_redirect', 'check_prof_page_CIPF', 11);
|
|
|
|
|
|
|
|
?>
|