- 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
|
* but 'init' already has set user, so we can recreate the functions
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function redirects_home_if_not_partner() {
|
//function redirects_home_if_not_partner() {
|
||||||
Plgntls::debug_infos(2);
|
// Plgntls::debug_infos();
|
||||||
$role_partner = Cipf::ROLE_PARTNER;
|
// $role_partner = Cipf::ROLE_PARTNER;
|
||||||
|
//
|
||||||
if (!is_user_logged_in_CIPF()) {
|
// if (!is_user_logged_in_CIPF()) {
|
||||||
redirect_home_CIPF();
|
// redirect_home_CIPF();
|
||||||
}
|
// }
|
||||||
if (!current_user_can_CIPF($role_partner)) {
|
// if (!current_user_can_CIPF($role_partner)) {
|
||||||
redirect_home_CIPF();
|
// redirect_home_CIPF();
|
||||||
}
|
// }
|
||||||
Plgntls::debug_infos();
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ function is_partner_form_creation_page_CIPF() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* only for the partner form creation page
|
* 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)) {
|
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() {
|
function partner_form_creation_page_init_CIPF() {
|
||||||
Plgntls::debug_infos(2);
|
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
|
// https://developer.wordpress.org/reference/functions/get_query_var/#more-information
|
||||||
global $wp;
|
global $wp;
|
||||||
@@ -57,7 +64,9 @@ add_action('init','partner_form_creation_page_init_CIPF');
|
|||||||
function partner_form_creation_page_CIPF() {
|
function partner_form_creation_page_CIPF() {
|
||||||
Plgntls::debug_infos(2);
|
Plgntls::debug_infos(2);
|
||||||
|
|
||||||
redirects_home_if_not_partner();
|
if (!is_partner()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!is_partner_form_creation_page_CIPF()) {
|
if (!is_partner_form_creation_page_CIPF()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,10 @@ class Plgntls {
|
|||||||
* typical for early hooks like 'init' or 'wp', where there is a first check to see if you should 'enter' in this function, level 1 will be present after thoses checks
|
* typical for early hooks like 'init' or 'wp', where there is a first check to see if you should 'enter' in this function, level 1 will be present after thoses checks
|
||||||
* 2 : output everything
|
* 2 : output everything
|
||||||
*
|
*
|
||||||
*/
|
private static $_DEBUG_INFOS = 1;
|
||||||
private static $_DEBUG_INFOS = 2;
|
private static $_DEBUG_INFOS = 2;
|
||||||
|
*/
|
||||||
|
private static $_DEBUG_INFOS = 0;
|
||||||
|
|
||||||
private static $_instance_count = 0;
|
private static $_instance_count = 0;
|
||||||
private static $_adding_count = 0;
|
private static $_adding_count = 0;
|
||||||
@@ -335,6 +337,7 @@ class Plgntls {
|
|||||||
$function = $trace[1]['function'];
|
$function = $trace[1]['function'];
|
||||||
$file = $trace[0]['file'];
|
$file = $trace[0]['file'];
|
||||||
$line = $trace[0]['line'];
|
$line = $trace[0]['line'];
|
||||||
|
error_log("-debug: function '".$function."' (in ".$file.", line ".$line .')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user