Join our new community forum for support & discussion

Join Now

Home Support General HivePress ‘vendor_view_page’ in the menu

‘vendor_view_page’ in the menu

  • Author
  • Ragab1805

    How to add a dynamic link in the menu to redirect the [vendor] to his [listings by vendor] or [vendor_view_page] page?

    ihor developer

    This would require some custom code snippet, because the URL is different for each user, and not all users are vendors. If you’re familiar with customizations please try using the get_post function to find the vendor ID by the user ID (the user is set as a vendor profile author).


    I tried to add this snippet to the php file so it can filter the listings page instead of filtering the link in the menu… But it didn’t work properly.
    So can you help me find out what went wrong with the snippet?

            function( $model ) {
    	$model['fields']['user']['type']['id'] = ['fields']['vendor']['type']['id']  ;
    	return $model;

    After reaching out to my client he refused the filtering solution and insisted to the link in the menu,, so if you can give me a hint about how to do it or where to start cuz I didn’t really understood how can I customize the links in the menu… I will be very grateful.
    Thanks in advance ๐Ÿ™‚

    ihor developer

    Menus are related to the core WordPress features, please check the code snippets here You can try checking the current user ID, then get the vendor ID and if it’s available get URL via the get_permalink() function. Hope this helps.


    If youโ€™re familiar with customizations please try using the get_post function to find the vendor ID by the user ID (the user is set as a vendor profile author).

    sample code?

    ihor developer

    You can try this one:

    $vendor_id = HivePress\Models\Vendor::query()->filter(
    		'status' => 'publish',
    		'user'   => get_current_user_id(),

    This code did not work for me (((
    used in functions.php

    ihor developer

    It should work fine if the current user has a published vendor profile, otherwise the $vendor_id will contain null.


    try this. put this code in child theme function.php file

    add_filter( 'hivepress/v1/menus/user_account',   'alter_user_account_menu_register1'  );
    function alter_user_account_menu_register1( $menu ) {    
        global $wpdb;
        $p_sql = "SELECT <code>post_name</code> FROM wp_posts WHERE <code>post_author</code>=".get_current_user_id()." AND <code>post_type</code>='hp_vendor'";
        $row = $wpdb->get_results($p_sql);
        if(count($row) > 0){
            $menu['items']['vender'] = [        
                'label' => "Listing page ",
                'url'   => esc_url( home_url()."/vendor/".$row[0]->post_name ),
                '_order' => 14,
    return $menu;
    ihor developer

    @fekedew Thanks for sharing!


    Hi. I tried the code which @fekedew gave above. but the URL still show the default vendor’s link.

    Do I only need to put the code to function.php child theme? or do I need to add more code to some where else? What am I missing?

    Please help me with this. I think vendor should be able to see how they are displayed on vendor listing page easily by clicking a link.

    Thank you in advance!

    ihor developer

    Sorry, I haven’t tested the above code snippet, maybe @fekedew will clarify. Adding the vendor profile link to the account page is possible, but requires customizations.


    Hi everyone.
    I came up with a different solution.
    Instead of showing a link on Navbar, I managed to put a link within a my account menu.

    I hope this will help ๐Ÿ™‚

    //Add a link to My listing page within my account menu
    	function( $menu ) {
    		$menu['items']['custom_item_name'] = [
    			'label'  => 'My Listings',
    			'url'    => esc_url( home_url()."/vendor/".get_display_name()),
    			'_order' => 123,
    		return $menu;
    function get_display_name () {
    	$user_data = get_userdata(get_current_user_id());
    	return  $user_data->display_name;

    I don’t know much about PHP I just combined these POSTS.

    Thanks @ihor @Sergio @RooninStark

    ihor developer

    Thanks for sharing!

Viewing 15 posts - 1 through 15 (of 15 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.