By default, Dokan vendors have to go to the vendor dashboard to find a link to their store. This works just fine in most cases, but what if we wanted to link directly to the current user’s store in the main menu and avoid this additional step? In this article we outline one possible solution.

Step 1: Add code snippet to functions.php

To get started, copy the following code snippet and paste it in your theme’s functions.php file. Please note that you should omit the opening <?php tag when copying this snippet. Just copy the bits from lines 3 to 42.

If you’re not PHP literate you might be wondering exactly what this code does. Put simply, it enables you add a WP menu item with the URL #dokan-my-store and have it linked to the current user’s store automatically on the frontend. It also handles hiding menu items with this special URL when Dokan is not active or the current user is not a Dokan vendor.

Step 2: Add menu item

The next and final step involves adding a new Custom Link menu item in your menu where you want the “My Store” link to appear. Here’s how you can do that:

  • Navigate to Appearance > Menus in WP Admin.
  • Select the menu where you want the “My Store” link to appear.
  • In the left sidebar, select Custom Links.
  • Enter #dokan-my-store in the URL field.
  • Enter the desired title for the menu item in the Link Text field.
  • Click Add to Menu.
  • When the new menu item appears in the menu, click Save Menu.

For example, here’s how you would configure the URL and Link Text fields to add a new menu item “View Store” linking to the current user’s Dokan store:

Adding a “View Store” menu item in Dokan

That’s it! Now you should have a menu item linking to the current user’s Dokan store. If Dokan is not active or the current user is not a vendor it should be hidden automatically.

Have any questions about how to use this snippet? Need help with another Dokan customization? Drop a comment below and we’ll get back to you ASAP.

Leave a Reply

Your email address will not be published. Required fields are marked *