- 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

@@ -54,15 +54,13 @@ function prof_profil_redirects_CIPF() {
PLGNTLS_class::debug_infos();
$role_fipf = PLGNTLS_class::ROLE_FIPF;
$role_admin = PLGNTLS_class::ROLE_ADMIN;
$role_partner = PLGNTLS_class::ROLE_PARTNER;
// is an author page
if (!is_author())
return;
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
$current_user = wp_get_current_user();
/*
* check multiple user roles
@@ -70,26 +68,30 @@ function prof_profil_redirects_CIPF() {
* if user->role is found in array of allowed role, no redirection needed
*
*/
$current_user = wp_get_current_user();
$allowed_roles = array($role_admin, $role_fipf);
if (array_intersect($allowed_roles, $current_user->roles))
return;
/*
* both 'get_queried_object_id' and 'get_the_author_meta' works here,
* i don't knwo why it's not alwasy the case :
*
$author_id = get_the_author_meta( 'ID' );
*/
$author_id = get_queried_object_id();
$current_user_id = get_current_user_id();
/*
* if partner, redirect
*
*/
if (current_user_can($role_partner)) {
redirect_home_CIPF();
}
/*
* if connected user is not author, get out
*
*/
// the way to find the id of the author of an author_page
$author_id = get_queried_object_id();
$current_user_id = get_current_user_id();
if ($current_user_id != $author_id) {
redirection_profil_CIPF();
redirect_home_CIPF();
}
}