Having issues adding multiple if menu conditions
-
Hi there, love this plugin!!!
I’ve added a few custom conditions using the code you supply on the plugin page. The first (Documentation) works fine. The rest end up all being ignored when saving on the dashboard menu screen. For instance, if I save it to “Is 3A Member” or “Is 3A Candidate”, it always defaults to the last item “Is Instructor”. I can see the settings and select them, but when pressing save, it always defaults back to “Is Instructor”.
// Document add_filter( 'if_menu_conditions', 'my_new_menu_condition' ); function my_new_menu_condition( $conditions ) { $conditions[] = array( 'name' => 'Single Document', // name of the condition 'condition' => function($item) { // callback - must return TRUE or FALSE return is_singular( 'documentation' ); }, 'group' => 'Page type' ); return $conditions; } // 3A Candidate add_filter( 'if_menu_conditions', 'menu_candidate_membership_condition' ); function menu_candidate_membership_condition( $conditions ) { $conditions[] = array( 'name' => 'Is 3A Candidate', // name of the condition 'condition' => function($item) { // callback - must return TRUE or FALSE return wc_memberships_is_user_active_member( $user_id, '3a-candidate' ); }, 'group' => 'Memberships' ); return $conditions; } // 3A Member add_filter( 'if_menu_conditions', 'menu_3a_member_membership_condition' ); function menu_3a_member_membership_condition( $conditions ) { $conditions[] = array( 'name' => 'Is 3A Member', // name of the condition 'condition' => function($item) { // callback - must return TRUE or FALSE return wc_memberships_is_user_active_member( $user_id, '3a-member' ); }, 'group' => 'Memberships' ); return $conditions; } // 3A Student add_filter( 'if_menu_conditions', 'menu_3a_student_membership_condition' ); function menu_3a_student_membership_condition( $conditions ) { $conditions[] = array( 'name' => 'Is 3A Student', // name of the condition 'condition' => function($item) { // callback - must return TRUE or FALSE return wc_memberships_is_user_active_member( $user_id, '3a-student' ); }, 'group' => 'Memberships' ); return $conditions; } // 3A Instructor add_filter( 'if_menu_conditions', 'menu_membership_condition' ); function menu_membership_condition( $conditions ) { $conditions[] = array( 'name' => 'Is Instructor', // name of the condition 'condition' => function($item) { // callback - must return TRUE or FALSE return wc_memberships_is_user_active_member( $user_id, '3a-instructor' ); }, 'group' => 'Memberships' ); return $conditions; }
Is it better to wrap them all in one function in one array?
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Having issues adding multiple if menu conditions’ is closed to new replies.