• 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?

LPH

Well-known member
#1
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.


Code:
                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/'. $user_id .'">'.$current_user->display_name.'</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>';
                }

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


UPDATE:

This appears to work !

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

Jake Bunce

XenForo moderator
Staff member
#2
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.
 

LPH

Well-known member
#3
Thank you Jake. Next is figuring out how to get the dropdowns then alerts to show in the new WP menus. :)