Support » Plugin: If Menu - Visibility control for Menu Items » Custom conditions for Wishlist member levels

  • I’m trying to create custom conditions to show WishList member levels in If Menu and then allow the If Menu logic to work on the member level (same way that it does with WP user roles.

    I’m close (see code below). I can get all the WL Levels to show up for Menu Admin, and can select the condition. But for some reason I can’t get the user Front end to work with it… I can’t seem to get the conditional logic to evaluate to true and show a menu item. Looking at the array I have something like,

    name, condition, group

    … and when I echo the array I can see that the condition value = 1. But it just doesn’t validate as true and enable the menu item on the front end. Any ideas?

    // If Menu theme's functions.php or plugin file
    // For adding WishList member levels to If Menu conditions
    add_filter( 'if_menu_conditions', 'wlm_menu_condition' );
    function wlm_menu_condition( $conditions ) {
    	//Navigate down to the levels array
         $levels = wlmapi_the_levels();
    	$levels_array = $levels['levels']['level'];
    	$member_id = get_current_user_id();
    	Foreach ( $levels_array as $level) {
    		$level_id = $level[id];
    		$level_name = $level[name];
    		$check = wlmapi_is_user_a_member( $level_id, $member_id);
              //echo( 'level_id = ' . $level_id) . ' | ';
              //echo( 'level_name = ' . $level_name) . ' | ';
              //echo( 'check = ' . $check);
              //echo( '<br>');
              //die('VALUE IS: ' . $level_name)   ;
    		$conditions[] = array(
    			'name'    =>  $level_name,  // name of the wl member level
    			'condition' =>  $check,
    			'group'     =>  'WL Level' 
    	return $conditions;


    • This topic was modified 2 years, 9 months ago by Norm Sash.
  • The topic ‘Custom conditions for Wishlist member levels’ is closed to new replies.