Added conditions callback not invoked
-
Added filter and condition for ‘Is NOT logged in’ – complement to the Is logged in provided – want to display specific menu items including to a login page.
Code added:
add_filter( 'if_menu_conditions', 'gmcdesign_if_menu_conditions' ); function gmcdesign_if_menu_conditions( $conditions ) { gmcdesign_debug_log('gmcdesign_if_menu_conditions invoked'); gmcdesign_debug_log($conditions); $conditions[] = array( 'id' => 'is-not-logged-in', 'name' => 'Is NOT logged in', // name of the condition 'condition' => 'gmcdesign_is_user_not_logged_in', // callback - must return TRUE or FALSE // 'condition' => function() { // callback - must return TRUE or FALSE // if (is_user_logged_in()) return FALSE; // return TRUE; // } ); gmcdesign_debug_log($conditions); return $conditions; } function gmcdesign_is_user_not_logged_in() { gmcdesign_debug_log('gmcdesign_is_user_not_logged_in invoked'); if (is_user_logged_in()) return FALSE; return TRUE; }
Requested menu item doesn’t appear.. (A ‘Login’ submenu uner the ‘Membership’ tab)
Note from Debug log below:
– shows entry to the add_filter defined function
– EMPTY $conditions passed to filter function
– Populated $conditions on return from filter function
– callback function for new addition never called
– undefined index in /plugins/if-menu/if-menu.php on line 110[24-Feb-2021 17:13:12 UTC] gmcdesign_if_menu_conditions invoked
[24-Feb-2021 17:13:12 UTC] Array
(
)[24-Feb-2021 17:13:12 UTC] Array
(
[0] => Array
(
[id] => is-not-logged-in
[name] => Is NOT logged in
[condition] => gmcdesign_is_user_not_logged_in
))
[24-Feb-2021 17:13:12 UTC] PHP Notice: Undefined index: in /home/michiganwood/www/staging2/wp-content/plugins/if-menu/if-menu.php on line 110
[24-Feb-2021 17:13:12 UTC] PHP Notice: Trying to access array offset on value of type null in /home/michiganwood/www/staging2/wp-content/plugins/if-menu/if-menu.php on line 110
[24-Feb-2021 17:13:12 UTC] PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in /home/michiganwood/www/staging2/wp-content/plugins/if-menu/if-menu.php on line 110The page I need help with: [log in to see the link]
- The topic ‘Added conditions callback not invoked’ is closed to new replies.