- creates redirect-home function
- restrict prof form to profs - restrict paypal page for prof only
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user