Okay
  Public Ticket #3095376
Hide Menus Based on Role
Closed

Comments

  •  6
    Todd Jones started the conversation

    Does the plugin manage menu visibility based on the user's logged-in status and role?  If so, how do I get that to function on my site.  Currently, my site shows all the menu options to all visitors to the site.  Non-logged-in users see the Checkout, Checkout Results, My Account, Products, and Vendor Dashboard.  These options should be hidden for visitors who are not logged into the site.  Buyers who are not registered as vendors should not see the Products, Shop, and Vendor Dashboard.

  •  1,906
    WebWizards replied

    Hi Todd,

    The plugin doesn't have a direct feature for controlling menu visibility. However, I think you could just hide menu items by using the plugin's CSS classes.

    The plugin adds the following classes:

    - marketking_vendor

    - marketking_not_vendor

    - marketking_vendor_group_1234 where 1234 is the ID of the group.


    So for example, to hide the Vendor Dashboard page in the menu for users who are not logged in vendors, you can add this css:

    .marketking_not_vendor .page-item-380{
        display:none !important;
    }

    With Google Chrome you can right click -> inspect and see what class each menu item has:

    9264728238.png

    You can see the vendor dashboard has .page-item-380



    If that would help, I can also add some more classes for logged in, and not logged in users.

    Kind regards,

    Stefan

  •  6
    Todd Jones replied

    Thank you.  I"ll see if I can get it to work.  Your directions make it seem straight forward.  In the past I've used a plug-in to adjust visibility.  I suppose it would be possible to use a standard Wordpress menu with shortcodes so I could use the visibility plugin.

  • tomasburok replied

    There is wordpress plugin "If Menu - Visibility control for menus"

    It would work fine if the user role would change after registering as a vendor. Now it stays as customer under "all users". You have to manually change the user role of the vendor to subscriber or etc, to hide and show the menu.



  •  1,906
    WebWizards replied

    It is possible to make the plugin sync the group with a WP role. For that, add this PHP code snippet:

    add_filter('marketking_use_wp_roles','__return_true'); 

    And then deactivate and reactivate MarketKing.

    It will create a WP Role for each vendor group and will try to sync role and group.