Add Register next login and make it disappear after

Hi there,
I had a look at this topic and have the same request. I have managed to add the Register link in the header.php child theme, but after logging in it does not disappear. Any idea what I can tweak to make it do that?

<div class="header-navbar__middle">
						<nav class="header-navbar__menu" data-component="menu">
							<?php
							wp_nav_menu(
								[
									'theme_location' => 'header',
									'container'      => 'ul',
									'items_wrap'     => '<ul id="%1$s" class="%2$s" data-component="inherit-color" data-source="body" data-target=".current-menu-item" data-saturation="22" data-light="-5">%3$s<li class="menu-item menu-item--last menu-item--user-login"> <a href="#user_register_modal" class="hp-menu__item hp-menu__item--user-login hp-link"><span>Registro Empresa</span> </a></li></ul>',

The change is in the last line, with the il add.

Hi,

Please specify more details about what exactly you need to add, and we will try to suggest a solution or a workaround. Or please send a link to this topic, as it’s not entirely clear what goal you want to get.

Sorry, the topic I meant was this one:

I figured this part out but the register link/button does not disappear after login. And on mobile the link does not show up but login does.

I believe tweaking your code like this should do.

<?php
//display register button only when not logged-in
if ( !is_user_logged_in() ) {

or this :

if( !is_user_logged_in() ){
    wp_nav_menu( array( 'theme_location' => 'primary-loggedout' ) );
} else {
    wp_nav_menu( array( 'theme_location' => 'primary-menu' ) );
}
1 Like

Genius, thanks! I modified the ! as to an if the isuer is logged in, but otherwise worked perfectly!

<?php
							if( is_user_logged_in() ){
								wp_nav_menu(
								[
									'theme_location' => 'header',
									'container'      => 'ul',
									'items_wrap'     => '<ul id="%1$s" class="%2$s" data-component="inherit-color" data-source="body" data-target=".current-menu-item" data-saturation="22" data-light="-5">%3$s</ul>',
								]
							);
							} else {
							wp_nav_menu(
								[
									'theme_location' => 'header',
									'container'      => 'ul',
									'items_wrap'     => '<ul id="%1$s" class="%2$s" data-component="inherit-color" data-source="body" data-target=".current-menu-item" data-saturation="22" data-light="-5">%3$s<li class="menu-item menu-item--last menu-item--user-login"> <a href="#user_register_modal" class="hp-menu__item hp-menu__item--user-login hp-link"><span>Registro Empresa</span> </a></li></ul>',
								]
							);
							}
							?>
1 Like

The only thing that still happens is that the Register link disappears on mobile. Not sure why?

Holaaaaaaaa

Please provide your site name and I may have a look.
Always curious to see what others are managing to achieve.

I saw that one site featured in the showcase section use a handy plugin for mobile :

And here the result (see bottom menu ?)

He also added a back-to-top feature thanks to another plugin (see the blue square with an upwards arrow in the bottom right corner ?) , which is handy and missing in any hivepress theme.

In your case, it’s either the menu for mobile is different, or you need to tweak some CSS (some display:none directive you may need to remove) .

Saludos.

Ok, thanks I will take a look.

Our site is https://merlin.com.es/

Fixed it on tablets with also doing the change on the burger menu. However, this still does not work on mobile.

<div class="header-navbar__end">
						<div class="header-navbar__burger" data-component="burger">
							<a href="#"><i class="fas fa-bars"></i></a>
							<?php
							if( is_user_logged_in() ){
								wp_nav_menu(
								[
									'theme_location' => 'header',
									'container'      => 'ul',
									'items_wrap'     => '<ul id="%1$s" class="%2$s" data-component="inherit-color" data-source="body" data-target=".current-menu-item" data-saturation="22" data-light="-5">%3$s</ul>',
								]
							);
							} else {
							wp_nav_menu(
								[
									'theme_location' => 'header',
									'container'      => 'ul',
									'items_wrap'     => '<ul id="%1$s" class="%2$s" data-component="inherit-color" data-source="body" data-target=".current-menu-item" data-saturation="22" data-light="-5">%3$s<li class="menu-item menu-item--last menu-item--user-login"> <a href="#user_register_modal" class="hp-menu__item hp-menu__item--user-login hp-link"><span>Registro Empresa</span> </a></li></ul>',
								]
							);
							}
							?>
						</div>
						<?php if ( has_filter( 'hivetheme/v1/areas/site_header' ) ) : ?>
							<div class="header-navbar__actions">
								<?php echo apply_filters( 'hivetheme/v1/areas/site_header', '' ); ?>
							</div>
						<?php endif; ?>
					</div>

I have fixed it now with the bottom nav bar you suggested, looks really good!

1 Like

I saw you also added the smooth back to top plugin.
I did the same :wink:
Estamos en la misma pagina.

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