redirections whould work now
This commit is contained in:
@@ -26,17 +26,22 @@ function redirection_profil_CIPF(){
|
||||
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
|
||||
nocache_headers();
|
||||
|
||||
error_log("- in redirection_profil_CIPF");
|
||||
|
||||
if (!is_user_logged_in()) {
|
||||
error_log("user not logged in");
|
||||
wp_redirect($base_url, 301);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (current_user_can($role_prof)) {
|
||||
error_log("user is prof");
|
||||
$user_page = get_author_posts_url($current_user_id);
|
||||
wp_redirect($user_page, 301);
|
||||
exit;
|
||||
}
|
||||
else if (current_user_can($role_partner)) {
|
||||
error_log("user is partner");
|
||||
$args = array(
|
||||
'post_type' => 'post',
|
||||
'author' => $current_user_id,
|
||||
@@ -55,6 +60,7 @@ function redirection_profil_CIPF(){
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
error_log("else");
|
||||
wp_redirect($base_url, 301);
|
||||
exit;
|
||||
}
|
||||
@@ -65,16 +71,20 @@ function redirection_profil_CIPF(){
|
||||
|
||||
|
||||
/*
|
||||
* version 1:
|
||||
* redirects when on the page with slug defined in SLUG_PAGE_REDIRECTION
|
||||
* version 3:
|
||||
* redirects when trying to access the page with SLUG_PAGE_REDIRECTION
|
||||
* no matter if it exists or not
|
||||
*
|
||||
*/
|
||||
function redirection_page_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
|
||||
if (!is_page($slug_page_redirection))
|
||||
global $wp;
|
||||
$current_slug = $wp->request;
|
||||
if ($current_slug !== $slug_page_redirection) {
|
||||
return;
|
||||
}
|
||||
|
||||
redirection_profil_CIPF();
|
||||
}
|
||||
@@ -84,6 +94,27 @@ add_action('template_redirect', 'redirection_page_CIPF');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* version 1:
|
||||
* redirects when on the page with slug defined in SLUG_PAGE_REDIRECTION
|
||||
*
|
||||
*/
|
||||
//function redirection_page_CIPF(){
|
||||
// PLGNTLS_class::debug_infos();
|
||||
// $slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
//
|
||||
// if (!is_page($slug_page_redirection)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// redirection_profil_CIPF();
|
||||
//}
|
||||
//add_action('template_redirect', 'redirection_page_CIPF');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* version 2:
|
||||
* redirects when a specific url is requested : SLUG_PAGE_REDIRECTION
|
||||
|
||||
Reference in New Issue
Block a user