Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to Remove and Add Items in ”bp_get_displayed_user_nav” (37 posts)

Started 1 year, 8 months ago by: ri-kun

  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    ——————————————————————-
    TO UNDERSTAND MY QUESTION CLEARLY PLEASE VIEW THIS SCREENCAP I MADE:

    ——————————————————————-

    I am simply trying to remove the “blog” link and other items in the bp subnav for the profile section and would like to add other items/links… I am trying to gain some control over what items appear in the profile subnav..

    I cannot seem to determine where BP decides what items get placed in the subnav array when is called.

    Do you have any light to shine on how user nav’s are set as “display-able”.. is there a place where which subnav items are supposed to be display are determined?

    ——————————————————————-
    TO UNDERSTAND MY QUESTION CLEARLY PLEASE VIEW THIS SCREENCAP I MADE:

    ——————————————————————-

  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    help please….help please….help please….

  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    help please….help please….help please….

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    You could look at adding a filter on: bp_get_displayed_user_nav_ . $user_nav_item['css_id'] to remove the blog menu.

    Or, take a look at these functions in bp-core.php:

    function bp_core_new_nav_item( $args = ” )
    function bp_core_remove_nav_item( $parent_id )

  • Profile picture of Boone Gorges Boone Gorges said 1 year, 8 months ago:

    Roger’s right – bp_core_remove_nav_item() is the function you want. See bp-core.php to see how that function works.

    Also, please don’t bump your question more than once every few days. This board is not so well-trafficked that you can expect an answer to every question within a few hours, especially on the weekend.

  • Profile picture of Blogmudgeon Blogmudgeon said 1 year, 8 months ago:

    Sorry to say, a lot of us on the end publishing equation are not programmers… I used EngineSite to find the string, but have no clue as to where the parent ID for the menu item is to be found. even then, is it simply a matter of entering that ID into the argument?

    ‘/**
    * bp_core_remove_nav_item()
    *
    * Removes a navigation item from the sub navigation array used in BuddyPress themes.
    *
    * @package BuddyPress Core
    * @param $parent_id The id of the parent navigation item.
    * @param $slug The slug of the sub navigation item.
    */
    function bp_core_remove_nav_item( $parent_id ) {
    global $bp;

    /* Unset subnav items for this nav item */
    if ( is_array( $bp->bp_options_nav[$parent_id] ) ) {
    foreach( (array)$bp->bp_options_nav[$parent_id] as $subnav_item ) {
    bp_core_remove_subnav_item( $parent_id, $subnav_item['slug'] );
    }
    }

    unset( $bp->bp_nav[$parent_id] );’

    Thanks!

    P

  • Profile picture of Boone Gorges Boone Gorges said 1 year, 8 months ago:

    The following function, placed into your theme’s functions.php or bp-custom.php file, will remove the Blogs nav item from the Members section of the site:

    function boone_remove_blogs_nav() {
    	bp_core_remove_nav_item( 'blogs' );
    }
    add_action( 'bp_setup_nav', 'boone_remove_blogs_nav', 15 );

    Other top-level nav items can be removed by replacing ‘blogs’ with the appropriate name. Subnav items will work in a similar way, except using bp_core_remove_subnav_item and the extra $parent_id argument:

    function boone_remove_friends_activity_nav() {
    	bp_core_remove_subnav_item( 'activity', 'friends' );
    }
    add_action( 'bp_setup_nav', 'boone_remove_friends_activity_nav', 15 );
  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    1. How about you want to remove more than one? what additional codes you need to add?

    2. This is an off topic but I wanted to get the code for the “Message”. I mean I wanted to put the link of the messages on each users sidebar. Like they can see anywhere they go in the site their message link, if theres a new message or not. Thanks in advance.

  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    And also regarding no.2 I wanted to transfer the links SETTING, FRIENDS, GROUPS and QUICKPOST in the sidebar but dont know where to get the codes from the nav to the sidebar.

  • Profile picture of Blogmudgeon Blogmudgeon said 1 year, 8 months ago:

    And that Sir, just brought my community site one step closer to production! I may not be a programmer, but I have had the good fortune of encountering many gracious ones across the years willing to help the hapless, hopeless, and helpless amongst the publisher ranks. Thank you!

    If you ever have issues with amateur radio gear, don’t hesitate to ask me… :-)

    P

  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    wait, I tried to add this on my bp-functions.php and functions.php but it didnt remove anything from the nav:

    <?php function boone_remove_blogs_nav() {
    	bp_core_remove_nav_item( 'Profile','Blogs','Quick Post','Messages','Friends','Groups','Points','Settings' );
    }
    add_action( 'bp_setup_nav', 'boone_remove_blogs_nav', 15 ); ?>
  • Profile picture of Boone Gorges Boone Gorges said 1 year, 8 months ago:

    @blogmudgeon Glad to help :)

    @ri-kun bp_core_remove_nav_item doesn’t take multiple arguments. Try something like:

    <?php function boone_remove_blogs_nav() {
    	bp_core_remove_nav_item( 'blogs' );
            bp_core_remove_nav_item( 'groups' );
    }
    add_action( 'bp_setup_nav', 'boone_remove_blogs_nav', 15 ); ?>

    Add additional lines for nav items you want to remove. And make them lowercase, as the names might be case-sensitive and they are almost certainly lowercase when they are initially added.

    functions.php, in your theme directory, is the appropriate place to put this. There should be no function called bp-functions.php.

  • Profile picture of ri-kun ri-kun said 1 year, 8 months ago:

    Thanks for the response @Boone Gorges

    Can you also please please please answer the 2nd question?:

    2. This is an off topic but I wanted to get the code for the “Message”. I mean I wanted to put the link of the messages on each users sidebar. Like they can see anywhere they go in the site their message link, if theres a new message or not. Thanks in advance.

    I wanted to transfer the links SETTING, FRIENDS, GROUPS and QUICKPOST in the sidebar but dont know where to get the codes from the nav to the sidebar.

  • Profile picture of Boone Gorges Boone Gorges said 1 year, 8 months ago:

    @ri-kun The answer to your second question is not straightforward, though it has been discussed before on this forum. I suggest posting it in another thread so that other users will be able to help you with it. You might also have a look at this plugin by @pollyplummer http://wordpress.org/extend/plugins/buddypress-sliding-login-panel/

  • Profile picture of Roger Coathup Roger Coathup said 1 year, 8 months ago:

    The other thread, with code for the number of messages / notifications, and link across is: http://buddypress.org/community/groups/installing-buddypress/forum/topic/hi-hi-everyone-how-can-i-get-the-message-url-or-the-number-of-messages-and-settings-url/