Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter leefee

    (@leefee)

    I’m back! (Been dealing with the snowstorm)

    Just tested it, and it seems to work just fine. Any jank was not visible to me.

    Thread Starter leefee

    (@leefee)

    I just tested the one I had downloaded from github (your first-pass). It seemed to work just fine in the customizer! The display mode radio worked as it should, the logged-in role checklist was also OK. I was able to select roles, and the menu items disappeared and showed when they were supposed to. I”m not sure if you meant the first-pass version from github, or the one listed on www.ads-software.com that I created the pseudo-role for, but I’m guessing the ‘hide-for’ first pass. I’ve spent the last two years almost exclusively muddling through other peoples’ code, so my heart goes out to you!

    Thread Starter leefee

    (@leefee)

    FYI, I still have that version from yesterday installed. I was just working on some of our menus in our theme customizer (Appearance>Customize), and there it still just shows the old version – no “hide” option.

    Thread Starter leefee

    (@leefee)

    ..and woocommerce of course. I can’t believe I missed that one!

    Thread Starter leefee

    (@leefee)

    I tried it and it worked just great!

    I’m using flatsome theme and have the following plugins active:
    -Code Snippets
    -Elementor
    -Elementor Pro
    -Loco Translate
    -Marketship
    -Nextend Social Login
    -Plugins Load Order
    -ReviewX
    -TI Woocommerce wishlist
    -Toolset Types
    -WCFM
    -WCFM ultimate
    -WCFM multivendor marketplace
    -WCFM multivendor membership
    -WOOF – woocommerce products filter
    -WP Mail SMTP Pro
    -WPvivid Backup Plugin
    -YIKES Simple Taxonomy Ordering

    Thread Starter leefee

    (@leefee)

    I’d be happy to take a look! I’ll check it out this evening.

    I ended up making a “pseudo-role” for now, and it worked great.

    /*
     * Add custom roles to Nav Menu Roles menu list
     * param: $roles an array of all available roles, by default is global $wp_roles 
     * return: array
     */
    function lf_new_nav_menu_roles( $roles ){
      $roles['not-vendor'] = 'Hide for vendor';
      return $roles;
    }
    add_filter( 'nav_menu_roles', 'lf_new_nav_menu_roles' );
    
    /*
     * Change visibilty of each menu item
     * param: $visible boolean
     * param: $item object, the complete menu object. Nav Menu Roles adds its info to $item->roles
     * $item->roles can be "in" (all logged in), "out" (all logged out) or an array of specific roles
     * return boolean
     */
    function lf_nav_menu_vendor_item_visibility( $visible, $item ){
      
      //Checkk that the role is there, etc..
      if( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'not-vendor', $item->roles ) ){
        
    	//Get current user roles if a user is logged in
    	$current_user_roles = array();
    	if (is_user_logged_in()) $current_user_roles = wp_get_current_user()->roles;
    	
    	//Hide the menu item if vendor.
    	if (is_user_logged_in() && in_array('vendor', $current_user_roles) ){
            $visible = false;
          }
    	 
    	
    	 //Otherwise, show it.
    	   else {
            $visible = false;
      
      
        }
      }
    	
    	
      return $visible;
    }
    
    add_filter( 'nav_menu_roles_item_visibility', 'lf_nav_menu_vendor_item_visibility', 10, 2 );
    
    ?>
Viewing 6 replies - 1 through 6 (of 6 total)