From b93a3298d2278597eefbbbeee608d8eaa762c9b0 Mon Sep 17 00:00:00 2001 From: asus Date: Wed, 20 Mar 2024 14:44:19 +0100 Subject: [PATCH] new profs redirects to command --- plugins/cipf_plugin/cipf_plugin.php | 2 +- plugins/cipf_plugin/php/hide_admin.php | 2 +- .../cipf_plugin/php/profs_form_commande.php | 8 ++++---- plugins/cipf_plugin/php/profs_profil.php | 8 ++++++++ plugins/cipf_plugin/php/redirections.php | 18 ++++++++++++++++++ plugins/cipf_plugin/utils/plgntls_class.php | 4 ++-- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index bb9f32d..4295b8b 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -4,7 +4,7 @@ Plugin Name: cipf_plugin Plugin URI: Description: Author: hugogogo -Version: 0.3.9 +Version: 0.3.10.1 Author URI: */ diff --git a/plugins/cipf_plugin/php/hide_admin.php b/plugins/cipf_plugin/php/hide_admin.php index 7b299e4..1e5b4e7 100644 --- a/plugins/cipf_plugin/php/hide_admin.php +++ b/plugins/cipf_plugin/php/hide_admin.php @@ -82,7 +82,7 @@ function restrict_admin_access_CIPF() { */ redirection_profil_CIPF(); } -add_action('init', 'restrict_admin_access_CIPF', 100); +//add_action('init', 'restrict_admin_access_CIPF', 100); diff --git a/plugins/cipf_plugin/php/profs_form_commande.php b/plugins/cipf_plugin/php/profs_form_commande.php index d2f541b..02270e2 100644 --- a/plugins/cipf_plugin/php/profs_form_commande.php +++ b/plugins/cipf_plugin/php/profs_form_commande.php @@ -71,14 +71,14 @@ add_action('df_after_process', 'prof_after_form_commande_CIPF', 10, 3); */ function prof_form_restrictions_CIPF(){ PLGNTLS_class::debug_infos(); - $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD; + $slug_command_card = PLGNTLS_class::SLUG_COMMAND_CARD; $role_prof = PLGNTLS_class::ROLE_PROF; // don't redirect if it is the divi builder mode if (et_fb_is_enabled()) { return; } - if (!is_page($slug_renew_card)) { + if (!is_page($slug_command_card)) { return; } @@ -103,9 +103,9 @@ add_action('template_redirect', 'prof_form_restrictions_CIPF'); */ function renew_page_filter_message_CIPF(){ PLGNTLS_class::debug_infos(); - $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD; + $slug_command_card = PLGNTLS_class::SLUG_COMMAND_CARD; - if (!is_page($slug_renew_card)) + if (!is_page($slug_command_card)) return; $user_id = get_current_user_id(); diff --git a/plugins/cipf_plugin/php/profs_profil.php b/plugins/cipf_plugin/php/profs_profil.php index a8c8350..d62cd69 100644 --- a/plugins/cipf_plugin/php/profs_profil.php +++ b/plugins/cipf_plugin/php/profs_profil.php @@ -131,6 +131,14 @@ function prof_profil_redirects_CIPF() { redirect_home_CIPF(); } + + /* + * if connected prof is new, redirect to form commande + * + */ + if (is_account_new_CIPF()) { + redirect_command_CIPF(); + } } add_action('template_redirect', 'prof_profil_redirects_CIPF', 11); diff --git a/plugins/cipf_plugin/php/redirections.php b/plugins/cipf_plugin/php/redirections.php index 69d3234..5f2fc5c 100644 --- a/plugins/cipf_plugin/php/redirections.php +++ b/plugins/cipf_plugin/php/redirections.php @@ -27,6 +27,24 @@ function redirect_home_CIPF(){ +/* +* redirects new prof to commande +* +*/ +function redirect_command_CIPF(){ + PLGNTLS_class::debug_infos(); + $slug_command_card = PLGNTLS_class::SLUG_COMMAND_CARD; + + // Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes + nocache_headers(); + + wp_redirect(home_url($slug_command_card), 301); + exit; +} + + + + /* * redirect users to profil * if prof -> author page diff --git a/plugins/cipf_plugin/utils/plgntls_class.php b/plugins/cipf_plugin/utils/plgntls_class.php index a0946ca..a6fe265 100644 --- a/plugins/cipf_plugin/utils/plgntls_class.php +++ b/plugins/cipf_plugin/utils/plgntls_class.php @@ -79,7 +79,7 @@ class PLGNTLS_class { // SLUG const SLUG_PROF_INACTIV = 'validation-en-cours'; - const SLUG_RENEW_CARD = 'commande'; + const SLUG_COMMAND_CARD = 'commande'; const SLUG_PAGE_REDIRECTION = 'redirection_cipf'; const SLUG_PAYPAL_PAGE = 'paiement'; const SLUG_PAYPAL_REDIRECTION_SUCCESS = self::SLUG_PAGE_REDIRECTION; @@ -132,7 +132,7 @@ class PLGNTLS_class { const ADMIN_VALIDATE_PROF_FIELD = 'admin_activate_prof_cipf'; // for admin_modif_prof.php - private static $_DEBUG_INFOS = false; + private static $_DEBUG_INFOS = true; private static $_plugin_dir_path; private static $_plugin_name; private static $_file_dir_path;