added redirection without need of a page, use it for paypal success or failure message already

This commit is contained in:
asus
2024-03-14 10:29:02 +01:00
parent 2f4a5bb9ef
commit ecc072e25b
9 changed files with 124 additions and 131 deletions

View File

@@ -30,14 +30,18 @@ function renew_page_restrictions_CIPF(){
$role_fipf = PLGNTLS_class::ROLE_FIPF;
$role_admin = PLGNTLS_class::ROLE_ADMIN;
$base_url = home_url();
if (!is_page($slug_renew_card))
return;
if (!is_user_logged_in()) {
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
wp_redirect($base_url, 301);
exit;
}
$base_url = home_url();
$current_user_id = get_current_user_id();
$current_user = wp_get_current_user();
$acf_id = 'user_'.$current_user_id;
@@ -59,6 +63,8 @@ function renew_page_restrictions_CIPF(){
if (current_user_can($role_prof)) {
$can_renew = get_field($acf_prof_can_renew['_name'], $acf_id);
if ($can_renew === false) {
// Set up nocache headers before redirecting : https://developer.wordpress.org/reference/functions/wp_safe_redirect/#user-contributed-notes
nocache_headers();
$redirect_url = home_url() . '/' . $slug_page_redirection;
wp_redirect($redirect_url, 301);
exit;