1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I pull user_id?

Discussion in 'XenForo Questions and Support' started by LPH, Oct 13, 2012.

  1. LPH

    LPH Well-Known Member

    I'm trying to get a link on a WP menu to go to the user_id members profile page. This is the code in the header.php. The user name is showing. Now, I am working on the link to the XF profile page.

                    if ( is_user_logged_in() ) {
                        wp_nav_menu( array( 'theme_location' => 'primary' ) );
                        global $current_user, $XF;
                        echo '<ul id="member" class="loggedin_menu_class">
                        <li><a href="/community/members/'. $user_id .'">'.$current_user->display_name.'</a></li>
                        <li><a href="/community/logout">Log Out</a></li>
                    } 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>

    In particular, this anchor area needs to work. :)
    /community/members/'. $user_id .'
    System Info:
    XF 1.1.3
    WP 3.4.x multisite enabled
    XenScripts bridge 1.1


    This appears to work !

    <a href="/community/members/'. strtolower($XF->visitor->get('username')) . '.' . $XF->visitor->get('user_id') .'">'.$current_user->display_name.'</a>
    Is there a better way?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I haven't used that bridge myself, but it appears that you have access to XF's visitor object which is ideal. Looks good to me.
  3. LPH

    LPH Well-Known Member

    Thank you Jake. Next is figuring out how to get the dropdowns then alerts to show in the new WP menus. :)

Share This Page