WordPress.org

Support

Support » Plugins and Hacks » CodeFlavors floating menu » [Resolved] Add Buddypress profile link

[Resolved] Add Buddypress profile link

  • Hey guys, I’ve been trying to get a profile link in my menu by using this code:

    // Filter wp_nav_menu() to add profile link
        add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
        function my_nav_menu_profile_link($menu) {
                if (!is_user_logged_in())
                        return $menu;
                else
                        $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('Visit your Awesome Profile') . '</a></li>';
                        $menu = $menu . $profilelink;
                        return $menu;
        }

    But it shows up in both menus…any idea of how to make it just show up in the floating menu?

    http://wordpress.org/extend/plugins/codeflavors-floating-menu/

Viewing 1 replies (of 1 total)
  • Plugin Author Constantin Boiangiu

    @constantinboiangiu

    Sorry for the delay, hope I’m not too late. Try this piece of code and let me know:

    /**
     * Filter to add Buddypress profile link
     */
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link', 10, 2 );
    /**
     * Callback function to add Buddypress profile link in floating menu
     *
     * @param string $items - html list of items
     * @param object $args - menu arguments
     */
    function my_nav_menu_profile_link( $items, $args ){
    	$is_floating_menu = CFM_LOCATION == $args->theme_location;
    	if (!is_user_logged_in() || !$is_floating_menu ){
    		return $items;
    	}
    
    	if( function_exists('bp_loggedin_user_domain') ){
    		$profile_link = sprintf('<li><a href="%1$s" title="%2$s">%2$s</a></li>',
    			bp_loggedin_user_domain( '/' ),
    			__('Visit your Awesome Profile')
    		);
           	$items .= $profile_link;
    	}	
    
    	return $items;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Add Buddypress profile link’ is closed to new replies.
Skip to toolbar