diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index 62f1ade..1b87998 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -2,9 +2,9 @@ /* Plugin Name: cipf_plugin Plugin URI: -Description: +Description: reset cgv, price works with acf label Author: hugogogo -Version: 0.2.9 +Version: 0.3.1 Author URI: */ @@ -42,7 +42,6 @@ include_once(PLGNTLS_class::root_path() . 'php/redirections.php'); include_once(PLGNTLS_class::root_path() . 'php/author_restriction.php'); include_once(PLGNTLS_class::root_path() . 'php/profs_profil.php'); include_once(PLGNTLS_class::root_path() . 'php/profs_form.php'); -//include_once(PLGNTLS_class::root_path() . 'php/reset_card_form.php'); include_once(PLGNTLS_class::root_path() . 'php/partners_register.php'); include_once(PLGNTLS_class::root_path() . 'php/partners_page.php'); diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index 1afb3db..bb10874 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -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 diff --git a/plugins/custer/user_infos.php b/plugins/custer/user_infos.php index bd23ad6..19f81c5 100644 --- a/plugins/custer/user_infos.php +++ b/plugins/custer/user_infos.php @@ -77,6 +77,7 @@ function output_list_front($array, $current_user, $user_id) { function current_user_infos($atts) { $is_important = false; + /* * choose the default id target : * - logged_in diff --git a/private b/private index 33f4d57..eeb11c4 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 33f4d57f8df95a6a8c357d127c6f976fecd191ae +Subproject commit eeb11c4f5adc7d7dcd3e4b11d4f8369e3970736a