Disable fallback to account/settings when user has no listings

Hi!

I am hiding the entire HP menu to make all the HP profile sections unaccessable for users, since everything I need is covered through buddyboss/better messages.

The only thing apart from “search” and “add listing”, I really need is an additional “my listings” button, routing to account/listings, so users can edit their own listings.

However, if the user does not have any listings yet, account/listings is being auto-redirected to account/settings…

Is there a way (snippet), that would disable the re-routing and would instead only display an empty “My Listings” page?

Or anything like that?

Or any other good idea for a halfway elegant workaround here?

Any help is highly appreciated!

Hi,

In our extension, if there is no content on the page in the account, you will be redirected to the first menu item in the account (the first available). If you need to change this, it will require a custom implementation. The easiest option is to add a redirect for the settings themselves so that you are redirected to where you need to go (you can use a PHP snippet or third-party plugins, if available).

Awesome! Thank you for that tip! I was able to add a menu item with a link to a “you don’t have any listings yet” page at the right position with

<?php
add_filter(
	'hivepress/v1/menus/user_account',
	function( $menu ) {
		$menu['items']['custom_name_here'] = [
			'label'  => 'doesn't matter',
			'url'    => 'https://www.wonttell.haha/',
			'_order' => 30,
		];

		return $menu;
	}
);

I don’t exactly understand the order number thing, but maybe something like 10, 20, 30…?
However…
…it works!

Thank you!!
<3

1 Like

Hmm… obviously this code is causing an issue with elementor… it’s not loading anymore since I inserted the code… even though the code itself works… any ideas??

Hi,

I recommend checking the code format itself because mixed quotes are possible here: ‘doesn’t matter’ should cause a fatal error since there should be outer quotes first, then double quotes if there are single quotes inside.

?>
Thanks! But… No,…
I inserted that [doesn’t matter] and the [url] just here… and as I said… the code actually does it’s job.
It just… somehow… “causes elementor to ‘not finish loading’ anymore”

<?

Hi,

Please try to use this PHP snippet:

add_filter(
	'hivepress/v1/menus/user_account',
	function( $menu ) {
		$menu['items']['custom_name_here'] = [
			'label'  => "doesn't matter",
			'url'    => 'https://www.wonttell.haha/',
			'_order' => 30,
		];

		return $menu;
	}
);

Please note that it can require further customization.

​I hope this is helpful to you.

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