Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

closed as off-topic by kaiser Aug 4 at 14:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers 2

You could do something like this:

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

EDIT:

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' );
}
share|improve this answer
    
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. –  Nicola Sep 18 '12 at 20:17
1  
Please check if the edit works. –  Martin Hasan Sep 18 '12 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.

share|improve this answer

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