Add the listing submit link to the vendor account menu

Hello, I am trying to add the submit listing link to the account menu, I took this code from the HivePress github, but its not working

add_filter(
	'hivepress/v1/menus/user_account',
	function( $menu ) {
		$menu['items']['listing_submit']=[
			'label' => 'custom text here',
			'route' => 'listing_submit_page',
			'_order' => 123,
		];

Hello, I added this and it seems to work

add_filter(
    'hivepress/v1/menus/user_account',
    function ( $menu ) {
        if ( is_user_logged_in() ) {
            $vendor_id = HivePress\Models\Vendor::query()->filter(
                [
                    'user' => get_current_user_id(),
                ]
            )->get_first_id();

            if ( $vendor_id ) {
                $menu['items']['listing_submit'] = [
                    'label'  => 'Add Listing',
                    'url'    => hivepress()->router->get_url( 'listing_submit_page'),
                    '_order' => 123,
                ];
            }
        }

        return $menu;
    },
    1000
);
1 Like

Hello,

Below is the PHP code (Gist.github.com - Add the listing submit link to the user account menu) I use that works on my site.

add_filter(
	'hivepress/v1/menus/user_account',
	function( $menu ) {
		$menu['items']['listing_submit']=[
			'label' => 'custom text here',
			'route' => 'listing_submit_page',
			'_order' => 123,
		];

		return $menu;
	},
	1000
);

Thank you so much Valentin.M! Also the code i put is if someone wants to place the Add listing link only for vendors.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.