changed all role occurences by a const
This commit is contained in:
@@ -52,7 +52,9 @@ function renew_page_restrictions_CIPF(){
|
||||
PLGNTLS_class::debug_infos();
|
||||
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
||||
$slug_page_redirection = PLGNTLS_class::SLUG_PAGE_REDIRECTION;
|
||||
// $acf_prof_can_renew = PLGNTLS_class::ACF_PROF_CAN_RENEW;
|
||||
$role_prof = PLGNTLS_class::ROLE_PROF;
|
||||
$role_fipf = PLGNTLS_class::ROLE_FIPF;
|
||||
$role_admin = PLGNTLS_class::ROLE_ADMIN;
|
||||
|
||||
if (!is_page($slug_renew_card))
|
||||
return;
|
||||
@@ -72,7 +74,7 @@ function renew_page_restrictions_CIPF(){
|
||||
* https://developer.wordpress.org/reference/functions/current_user_can/#div-comment-4083
|
||||
*
|
||||
*/
|
||||
$allowed_roles = array('administrator', 'editor', 'professeur__professeure');
|
||||
$allowed_roles = array($role_admin, $role_fipf, $role_prof);
|
||||
if (!array_intersect($allowed_roles, $current_user->roles))
|
||||
return;
|
||||
|
||||
@@ -80,7 +82,7 @@ function renew_page_restrictions_CIPF(){
|
||||
* if prof, check card state
|
||||
* if cannot renew, redirect
|
||||
*
|
||||
if (current_user_can('professeur__professeure')) {
|
||||
if (current_user_can($role_prof)) {
|
||||
$can_renew = get_field($acf_prof_can_renew['_name'], $acf_id);
|
||||
if ($can_renew === false) {
|
||||
$redirect_url = home_url() . '/' . $slug_page_redirection;
|
||||
|
||||
Reference in New Issue
Block a user