• Welcome to Tux Reports: Where Penguins Fly. We hope you find the topics varied, interesting, and worthy of your time. Please become a member and join in the discussions.

Menu Enhanced: Includes Username

LPH

Flight Director
Flight Instructor
To get the WordPress side and XenForo side matching, the following was added to the header.php of a child theme. This adds the username with a link to the profile page within XenForo as well as a login/logout menu item.


PHP:
                <?php
                if ( is_user_logged_in() ) {
                    wp_nav_menu( array( 'theme_location' => 'primary' ) );

                    global $current_user, $XF;
                    get_currentuserinfo();

                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/members/'. strtolower($XF->visitor->get('username')) . '.' . $XF->visitor->get('user_id') .'">'.$current_user->display_name.'</a></li>
                    <li><a href="/community/conversations/">Inbox</a></li>
                    <li><a href="/community/logout">Log Out</a></li>
                    </ul>';

                } else {
                    wp_nav_menu( array( 'theme_location' => 'primary' ) );


                    echo '<ul id="member" class="loggedin_menu_class">
                    <li><a href="/community/login">Log In or Sign Up</a></li>
                    </ul>';
                }
                ?>

View on the Blog
 
Top