Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add dynamic menu link

Viewing 3 replies - 1 through 3 (of 3 total)
  • @danbp

    Participant

    Codex reference:

    Members Navigation Menus

    Also, on the forum, several topics, with many snippets:
    https://buddypress.org/support/search/bp_nav_menu/

    Here a working example, which add 2 external links on a profile.

    function bpfr_custom_setup_nav() {
      if ( bp_is_active( 'xprofile' ) )
    ?>
    <li><a href="<?php bp_members_directory_permalink(); ?>"><?php printf( __( 'All Members', 'buddypress' ) ); ?></a></li>
    <li><a href="http://buddypress.org" target="_blank" title="BP">BuddyPress</a></li>
    <?php  
    }
    add_action( 'bp_member_options_nav', 'bpfr_custom_setup_nav' );

    @trobertson82

    Participant

    im sorry i should have been clearer, http://mywebsite.com/members/username/activity/news-feed/ , is the destination i want the link to that destination to be in the main menu of the website

    @danbp

    Participant

    Try this:

    
    // depending the theme Main Menu, somwhere near Home, About, etc
    function bpfr_custom_setup_nav( $items) {
    	
        if ( is_user_logged_in() ) {		
            $items = '<li><a href="'. bp_get_loggedin_user_link() .'activity/news-feed/">News feed</a></li>';	
        }
        return $items;
    }
    // 10 is the priority, 1 is the position in the menu
    add_filter( 'wp_nav_menu_items', 'bpfr_custom_setup_nav', 10, 1 );
    
     

    References:

    wp_nav_menu_items


    https://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add dynamic menu link’ is closed to new replies.
Skip to toolbar