Free Directory, Listing & Classifieds WordPress Plugin Support General HivePress Re-Arrange My Account Menu Items

Re-Arrange My Account Menu Items

  • Author
    Posts
  • gsmobina

    I want to re-order the menu items on my account to the following:
    How can i do this?

    1. Listings
    2. Messages
    3. Favorites
    4. Membership
    5. Packages
    6. Orders
    7. Settings
    8. Sign out

    ihordeveloper

    You can do this via HivePress API using “hivepress/v1/menus/user_account” filter, menu items can be re-ordered in the same way as fields (via setting the “_order”).

    gsmobina

    like this?

    add_filter(
    	'hivepress/v1/menus/user_account',
    	function( $template ) {
    		return hivepress()->helper->merge_trees(
    			$template,
    			[
    				'blocks' => [
    				
    
    					'listings'          => [
    						'_order' => 0,
    					],
    						'messages' => [
    						'_order' => 1
    					],
    						'favorites' => [
    						'_order' => 3
    					],
    						'memberships' => [
    						'_order' => 4
    					],
    						'listung_packages' => [
    						'_order' => 5
    					],
    						'orders' => [
    						'_order' => 6
    					],
    						'settings' => [
    						'_order' => 7
    					],
    						'signout' => [
    						'_order' => 8
    					],
    				],
    			]
    		);
    	}
    );

    ——
    doesn’t seem to be working

    ihordeveloper

    Here’s an example:

    add_filter(
    	'hivepress/v1/menus/user_account/items',
    	function( $menu ) {
    		if ( isset( $menu['listings_edit'] ) ) {
    			$menu['listings_edit']['_order'] = 123;
    		}
    
    		return $menu;
    	}
    );
    gsmobina

    ok thank you. i’ll try this

    by the way is it possible to have a filter at the menu area? my client needs to show a country drop down, which by selecting will show only the selected country’s ads. I have set language and currency switcher dropdown for the site, so clients wants this dropdown next to this. if i am to do this, what best way would be this?

    gsmobina

    here is what i did. where am i gone wrong in this?

    add_filter(
    ‘hivepress/v1/menus/user_account/items’,
    function( $menu ) {
    if ( isset( $menu[‘listings_edit’] ) ) {
    $menu[‘listings_edit’][‘_order’] = 10;
    }
    if ( isset( $menu[‘messages’] ) ) {
    $menu[‘messages’][‘_order’] = 20;
    }
    if ( isset( $menu[‘favorites’] ) ) {
    $menu[‘favorites’][‘_order’] = 45;
    }
    if ( isset( $menu[‘memberships’] ) ) {
    $menu[‘memberships’][‘_order’] = 40;
    }
    if ( isset( $menu[‘user_listing_packages_view’] ) ) {
    $menu[‘user_listing_packages_view’][‘_order’] = 35;
    }
    if ( isset( $menu[‘woocommerce-orders’] ) ) {
    $menu[‘woocommerce-orders’][‘_order’] = 60;
    }
    if ( isset( $menu[‘user_edit_settings’] ) ) {
    $menu[‘user_edit_settingst’][‘_order’] = 70;
    }
    if ( isset( $menu[‘user_logout’] ) ) {
    $menu[‘user_logout’][‘_order’] = 80;
    }

    return $menu;
    }
    );

    ihordeveloper

    Try using this one instead:

    add_filter(
    	'hivepress/v1/menus/user_account/items',
    	function( $menu ) {
    		if ( isset( $menu['listings_edit'] ) ) {
    			$menu['listings_edit']['_order'] = 123;
    		}
    
    		return $menu;
    	},
    	10000
    );

    You can check page IDs with var_dump:

    var_dump($menu);

    For example, the favorites page has “listings_favorite” ID instead of “favorites”.

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

You must be logged in to reply to this topic.

Subscribe

Sign In

Don't have an account? Register

Forgot password?

Register

Already have an account? Sign In

Forgot password?

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.