I simply want to add some php in as a custom link in the wordpress menu section. The code I want to use is <?php bp_loggedin_user_domain(); ?> which will generate that logged in user's buddypress profile page url. However, when I paste that in as a custom links, wp removes the opening and closing tags and removes all the white space.

Any ideas?

2 Answers 2


You could do something like this:

if ( is_user_logged_in() ) {
     wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) );
} else {
     wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) );


Here is another try, same theory but different execution:

if ( is_user_logged_in() )
    // Filter wp_nav_menu() to add additional links and other output
    function new_nav_menu_items($items) 
        $homelink = '&lt;li class=&quot;home&quot;&gt;&lt;a href=&quot;' . bp_loggedin_user_domain() . '&quot;&gt;' . __('Profile') . '&lt;/a&gt;&lt;/li&gt;';
        $items = $homelink . $items;
        return $items;
    add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
  • no I don't want different menus if user logged in or out, I want to generate the custom link that the function bp_loggedin_user_domain() outputs.
    – Claire
    Sep 18, 2012 at 20:17
  • 1
    Please check if the edit works. Sep 18, 2012 at 22:48

Try using BP Menus plugin. It will add Buddypress menu items to Wordpress Menus and enable you to customize the menu from the dashboard.

Not the answer you're looking for? Browse other questions tagged or ask your own question.