- fixed error in plgntls debug logs
- fixed button partner modification page restrictions
This commit is contained in:
@@ -75,6 +75,55 @@ function current_user_can_CIPF($capability) {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* checks if current user is partner
|
||||
* works as soon as 'init' hook
|
||||
*
|
||||
* first hook to use is...() is parse_query
|
||||
* -> https://developer.wordpress.org/apis/hooks/action-reference/
|
||||
* - after 'init', before 'wp'
|
||||
* but 'init' already has set user, so we can recreate the functions
|
||||
*
|
||||
*/
|
||||
function is_partner() {
|
||||
Plgntls::debug_infos();
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
|
||||
if (!is_user_logged_in_CIPF()) {
|
||||
return false;
|
||||
}
|
||||
if (!current_user_can_CIPF($role_partner)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* checks if current user is prof
|
||||
* works as soon as 'init' hook
|
||||
*
|
||||
* first hook to use is...() is parse_query
|
||||
* -> https://developer.wordpress.org/apis/hooks/action-reference/
|
||||
* - after 'init', before 'wp'
|
||||
* but 'init' already has set user, so we can recreate the functions
|
||||
*
|
||||
*/
|
||||
function is_prof() {
|
||||
Plgntls::debug_infos();
|
||||
$role_prof = Cipf::ROLE_PROF;
|
||||
|
||||
if (!is_user_logged_in_CIPF()) {
|
||||
return false;
|
||||
}
|
||||
if (!current_user_can_CIPF($role_prof)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -143,18 +143,17 @@ add_action('template_redirect', 'redirection_page_CIPF');
|
||||
* but 'init' already has set user, so we can recreate the functions
|
||||
*
|
||||
*/
|
||||
function redirects_home_if_not_partner() {
|
||||
Plgntls::debug_infos(2);
|
||||
$role_partner = Cipf::ROLE_PARTNER;
|
||||
|
||||
if (!is_user_logged_in_CIPF()) {
|
||||
redirect_home_CIPF();
|
||||
}
|
||||
if (!current_user_can_CIPF($role_partner)) {
|
||||
redirect_home_CIPF();
|
||||
}
|
||||
Plgntls::debug_infos();
|
||||
}
|
||||
//function redirects_home_if_not_partner() {
|
||||
// Plgntls::debug_infos();
|
||||
// $role_partner = Cipf::ROLE_PARTNER;
|
||||
//
|
||||
// if (!is_user_logged_in_CIPF()) {
|
||||
// redirect_home_CIPF();
|
||||
// }
|
||||
// if (!current_user_can_CIPF($role_partner)) {
|
||||
// redirect_home_CIPF();
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ function is_partner_form_creation_page_CIPF() {
|
||||
|
||||
/*
|
||||
* only for the partner form creation page
|
||||
* first available hook is parse_query
|
||||
* -> https://developer.wordpress.org/apis/hooks/action-reference/
|
||||
* 584 : wordpress_docker/volumes/wp_volume/wp-includes/query.php
|
||||
* 4427 : wordpress_docker/volumes/wp_volume/wp-includes/class-wp-query.php
|
||||
*
|
||||
*/
|
||||
if (!is_page($slug_partner_create_page)) {
|
||||
@@ -39,7 +43,10 @@ function is_partner_form_creation_page_CIPF() {
|
||||
function partner_form_creation_page_init_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
|
||||
redirects_home_if_not_partner();
|
||||
if (!is_partner()) {
|
||||
return;
|
||||
}
|
||||
Plgntls::debug_infos();
|
||||
|
||||
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
|
||||
global $wp;
|
||||
@@ -57,7 +64,9 @@ add_action('init','partner_form_creation_page_init_CIPF');
|
||||
function partner_form_creation_page_CIPF() {
|
||||
Plgntls::debug_infos(2);
|
||||
|
||||
redirects_home_if_not_partner();
|
||||
if (!is_partner()) {
|
||||
return;
|
||||
}
|
||||
if (!is_partner_form_creation_page_CIPF()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user