wip author page checks, waiting page redirection working
This commit is contained in:
@@ -14,6 +14,8 @@ function restrict_author_page_CIPF() {
|
|||||||
if (!is_author())
|
if (!is_author())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
error_log("in restrict_author_page_CIPF");
|
||||||
|
|
||||||
$can_access = false;
|
$can_access = false;
|
||||||
if (current_user_can('administrator')) {
|
if (current_user_can('administrator')) {
|
||||||
$can_access = true;
|
$can_access = true;
|
||||||
@@ -33,7 +35,7 @@ function restrict_author_page_CIPF() {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action('template_redirect', 'restrict_author_page_CIPF');
|
add_action('template_redirect', 'restrict_author_page_CIPF', 10);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,35 +10,43 @@ if (!defined('ABSPATH')) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
function handle_prof_is_activ_CIPF($author_id) {
|
||||||
$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;
|
$acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV;
|
||||||
$slug_wait_activation = PLGNTLS_class::SLUG_PROF_INACTIV;
|
$slug_wait_activation = PLGNTLS_class::SLUG_PROF_INACTIV;
|
||||||
|
|
||||||
//$current_user = wp_get_current_user();
|
error_log("in handle_prof_is_activ_CIPF");
|
||||||
//$user_id = get_current_user_id();
|
|
||||||
//$acf_id = 'user_' . $user_id;
|
|
||||||
$acf_id = 'user_' . $author_id;
|
$acf_id = 'user_' . $author_id;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if prof is activ, do nothing more
|
||||||
|
*
|
||||||
|
*/
|
||||||
error_log("is activ ?");
|
error_log("is activ ?");
|
||||||
$is_activ = get_field($acf_prof_is_activ, $acf_id);
|
$is_activ = get_field($acf_prof_is_activ, $acf_id);
|
||||||
if ($is_activ === 'Actif')
|
if ($is_activ === 'Actif')
|
||||||
return;
|
return;
|
||||||
error_log("...is inactiv");
|
error_log("...is inactiv");
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
$redirection_prof_inactiv = home_url() . '/' . $slug_wait_activation;
|
||||||
error_log("redirection_prof_inactiv");
|
error_log("redirection_prof_inactiv");
|
||||||
error_log($redirection_prof_inactiv);
|
error_log($redirection_prof_inactiv);
|
||||||
@@ -49,4 +57,23 @@ function is_prof_activ_CIPF($author_id) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* series of check to do before printing a prof author page
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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();
|
||||||
|
|
||||||
|
handle_prof_is_activ_CIPF($author_id);
|
||||||
|
}
|
||||||
|
add_action('template_redirect', 'check_prof_page_CIPF', 11);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -145,9 +145,8 @@ function current_user_infos_CIPF($atts) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (is_array($atts)) {
|
if (is_array($atts)) {
|
||||||
$author = $atts['author'];
|
if (isset($atts['author'])) {
|
||||||
if (isset($author)) {
|
$author_is = $atts['author'];
|
||||||
$author_is = $author;
|
|
||||||
unset($atts['author']);
|
unset($atts['author']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
private
2
private
Submodule private updated: da67b9e9c0...f8fbd0231d
Reference in New Issue
Block a user