- creates redirect-home function

- restrict prof form to profs
- restrict paypal page for prof only
This commit is contained in:
asus
2024-03-20 01:02:46 +01:00
parent 0127d8db4c
commit 33adb095e5
5 changed files with 70 additions and 38 deletions

View File

@@ -22,9 +22,7 @@ function payment_page_checks_CIPF() {
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
// check the slug
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_paypal_page) {
if (!is_page($slug_paypal_page)) {
return;
}
@@ -39,24 +37,28 @@ add_action('wp', 'payment_page_checks_CIPF');
/*
* if profil needs redirection, it happens here
* only profs can access this page
*
*/
function payment_page_redirects_CIPF() {
PLGNTLS_class::debug_infos();
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
$role_prof = PLGNTLS_class::ROLE_PROF;
// check the slug
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_paypal_page) {
if (!is_page($slug_paypal_page)) {
return;
}
// get the user id
$user_id = get_current_user_id();
// do redirections here
/*
* if prof, don't redirect
* for everyone else, redirect
*
*/
if (current_user_can($role_prof)) {
return;
}
redirect_home_CIPF();
}
add_action('template_redirect', 'payment_page_redirects_CIPF');
@@ -73,9 +75,7 @@ function payment_page_scripts_CIPF() {
$slug_paypal_page = PLGNTLS_class::SLUG_PAYPAL_PAGE;
// check the slug
global $wp;
$current_slug = $wp->request;
if ($current_slug !== $slug_paypal_page) {
if (!is_page($slug_paypal_page)) {
return;
}