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.

8 comments

  1. I added this code into my child theme’s functions.php file and the menu link doesn’t work. The menu link takes the user to their vendor dashboard instead of their store. Is using my child theme’s functions.php as opposed to my regular theme’s functions.php affecting this? My website is running through the child theme which calls upon the regular theme. Thanks for any input!

    1. Hi Brooke, whether you’re using a parent theme or a child theme shouldn’t make a difference. Can you confirm that the menu item has the URL “#dokan-my-store” as depicted in the screenshot under step 2? Thanks!

    1. To open the link in a new tab:

      – Go to Appearance > Menus. Click Screen Options in the top right and make sure that “Link Target” is selected under “Show advanced menu properties”.
      – Edit the menu item with URL #dokan-my-store. Check the “Open link in a new tab” checkbox under the Navigation Label field.
      – Press Save Menu to save changes.

  2. Hi. Thanks for creating this.

    Is there a way to make this work with an Elementor button or link? Would appreciate the help.

Leave a Reply

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