I’ve gotten pretty far on this, but there are 2 niggles I can’t figure out:
-
When a user is not logged in, just show the “Log In” item and no dropdown under the community menu. Right now I have another Log In, in there, but even if I remove it, I end up with a blank drop down.
-
When a user is logged in, the Log In disappears from the main menu completely, and the Log Out appears along with the other items under the Community sub-menu.
// Custom Menus
/**- Community */
if ( ! function_exists( ‘x_bbpress_navbar_menu’ ) ) :
function x_bbpress_navbar_menu( $items, $args ) {
if ( X_BBPRESS_IS_ACTIVE && x_get_option( ‘x_bbpress_header_menu_enable’ ) == ‘1’ ) {
$submenu_items = ‘’;
if ( is_user_logged_in() ) {
$submenu_items .= ’ - Community */
- ’ . __( ‘Members’, ‘x’ ) . ‘ ’;
- ’ . __( ‘Favorites’, ‘x’ ) . ‘ ’;
- ’ . __( ‘Subscriptions’, ‘x’ ) . ‘ ’;
- ’ . __( ‘Downloads’, ‘x’ ) . ‘ ’;
- ’ . __( ‘Log in’, ‘x’ ) . ‘ ’;
- ’ . __( ‘Profile’, ‘x’ ) . ‘ ’;
- ’
. ‘’
. ’ ’ . __( ‘Community’, ‘x’ ) . ‘’
. ‘’
. ‘- ’
. $submenu_items
. ‘
. ‘ ’; - ’.wp_loginout($_SERVER[‘REQUEST_URI’], false).’ ’;
$submenu_items .= ’
$submenu_items .= ’
$submenu_items .= ’
}
if ( ! X_BUDDYPRESS_IS_ACTIVE || X_BUDDYPRESS_IS_ACTIVE && x_get_option( ‘x_buddypress_header_menu_enable’ ) == ‘’ ) {
if ( ! is_user_logged_in() ) {
$submenu_items .= ’
} else {
$submenu_items .= ’
$submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="/my-account" class="cf"><i class="x-icon-cog" data-x-icon="" aria-hidden="true"></i> <span>' . __( 'My Account', '__x__' ) . '</span></a></li>';
$submenu_items .= '<li class="menu-item menu-item-bbpress-navigation"><a href="' . wp_logout_url() . '" class="cf"><i class="x-icon-cog" data-x-icon="" aria-hidden="true"></i> <span>' . __( 'Log Out', '__x__' ) . '</span></a></li>';
}
}
if ( $args->theme_location == ‘primary’ ) {
$items .= ‘
}
}
return $items;
}
function autov_add_loginout_navitem( $items, $args ) {
if( $args->theme_location == ‘primary’ ){
$login_item = ‘
$items .= $login_item;
}
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘x_bbpress_navbar_menu’, 9996, 2 );
add_filter( ‘wp_nav_menu_items’, ‘autov_add_loginout_navitem’, 9997, 2 );
endif;