Hide the user account link

Is it possible to disable this menu item: “menu-item menu-item–user-account menu-item-has-children”. I need to do this with css code or there is a specific setting for this.

Thanks for help.

Wojciech

Hi!
If you need to hide the account menu item completely, please try this CSS snippet:

.header-navbar .menu-item--user-account{
 display: none;
}

hi @andrii, could you pls advise how to update the snippet to hide only “settings” from account menu item? thx!

Hi,
Please try this CSS snippet:

.menu-item .hp-menu__item--user-edit-settings {
	display: none;
}

Please note this snippet only hides this menu item from the front end. If the client has a link to this menu item, he can access it.

1 Like

Is there a way to completely hide it? Like a function? This is just a band aid and not enough because someone can still go into the CSS and remove the display: none;

We use a menu within WordPress to do all this, so we don’t want this link to appear in any fashion.

Yes, if you hide the link with CSS the page is still accessible directly by URL. You can try this code snippet to redirect the page:

add_filter(
	'template_redirect',
	function() {
		if ( hivepress()->router->get_current_route_name() === 'user_edit_settings_page' ) {
			wp_safe_redirect( home_url() );

			exit();
		}
	}
);

OK, but I’d really prefer a function to get rid of that link altogether so I could just have the ones in my nav menu.

Please use the suggested PHP snippet with the CSS snippet above, this will hide the link and redirect the page if someone tries to access it directly via URL.

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