Files
2024_WEBSITE_fipf/plugins/fipfcard_plugin/php/prof_check_page.php
asus d65af4cd43 - wip filter page prof
- upgraded user info shortcode to default behavior on author page
2024-03-07 17:05:55 +01:00

53 lines
1.1 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 check_prof_page_CIPF() {
// is an author page
if (!is_author())
return;
error_log("in check_prof_page_CIPF");
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
// is_prof_activ_CIPF($author_id);
}
add_action('template_redirect', 'check_prof_page_CIPF');
function is_prof_activ_CIPF($author_id) {
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
$slug_wait_activation = PLGNTLS_class::SLUG_PROF_INACTIV;
//$current_user = wp_get_current_user();
//$user_id = get_current_user_id();
//$acf_id = 'user_' . $user_id;
$acf_id = 'user_' . $author_id;
error_log("is activ ?");
$is_activ = get_field($acf_prof_is_activ, $acf_id);
if ($is_activ === 'Actif')
return;
error_log("...is inactiv");
$redirection_prof_inactiv = home_url() . '/' . $slug_wait_activation;
error_log("redirection_prof_inactiv");
error_log($redirection_prof_inactiv);
wp_redirect($redirection_prof_inactiv);
exit;
}
?>