Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_remove_nav_item'

Viewing 25 results - 1 through 25 (of 157 total)
  • Author
    Search Results
  • #323231
    kayart
    Participant
    function hide_friends_tabs_for_other_users() {
    	if ( bp_is_user() && !bp_is_my_profile() ) {
    		bp_core_remove_nav_item( 'friends' );
    		bp_core_remove_subnav_item( 'activity', 'friends' );
    	}
    }
    add_action( 'bp_setup_nav', 'hide_friends_tabs_for_other_users', 10 );
    ivanwancora
    Participant

    Hello

    We are making private groups without possibility of request membership. I remove the “request membership” button. But don’t can remove the “request-membership tab“ in the menu of the private group if you not are a member.
    I try this without success:

    function my_remove_em_nav() {
    global $bp;
    bp_core_remove_nav_item( 'request-membership' );
    
    }
    add_action( 'bp_init', 'my_remove_em_nav' );

    Someone knows how can we do this.

    nffox
    Participant

    One question. I’m trying to remove some menu items, but it only works if I add 2 different codes to functions.php and bp-custom.php.

    This one goes to functions.php

    function exclude_tab_if_not_personal_profile() {
        if ( ! bp_is_my_profile() ) {
            bp_core_remove_nav_item( 'friends' );
        }
    }
    add_action( 'bp_init', 'exclude_tab_if_not_personal_profile' );

    And this one to bp-custom.php

    function bp_remove_nav_item() {
        global $bp;
        bp_core_remove_subnav_item( $bp->profile->friends, 'change-avatar' );
    }
    add_action( 'wp', 'bp_remove_nav_item' );

    >>>>>>>>>>>>>>>
    It works… but

    1. The “friends” tabs appears in the profile (top navbar), and I just need it to appear in the profile menu (sidebar).

    2. Adding this piece of code for removing MORE items do nothing.
    The combination I used for bp-custom.php.

    function bp_remove_nav_item() {
        global $bp;
        bp_core_remove_subnav_item( $bp->profile->friends, 'change-avatar' );
        bp_core_remove_subnav_item( $bp->profile->forums, 'change-avatar' );
        bp_core_remove_subnav_item( $bp->profile->media, 'change-avatar' );
    }
    add_action( 'wp', 'bp_remove_nav_item' );

    and for functions.php

    function exclude_tab_if_not_personal_profile() {
        if ( ! bp_is_my_profile() ) {
            bp_core_remove_nav_item( 'friends' );
            bp_core_remove_nav_item( 'forums' );
            bp_core_remove_nav_item( 'media' );
        }
    }
    add_action( 'bp_init', 'exclude_tab_if_not_personal_profile' );

    Thanks, I would really appreciate any help, as apparently none of solutions found on this forum worked for me.

    shameem5566
    Participant

    I have to hide some nav menus of bp users’ profile page from other users. I using the following function to do so. That was working fine.

    /* BuddyPress profile nav menu restrictions */

    function bpex_hide_profile_menu_tabs()
    {

    if (bp_is_active(‘xprofile’)) :

    if (bp_is_user() && !bp_is_my_profile()) {
    // BP’s profile main menu items. Comment those to show.
    // bp_core_remove_nav_item( ‘activity’ );
    // bp_core_remove_nav_item(‘profile’);
    bp_core_remove_nav_item(‘friends’);
    bp_core_remove_nav_item(‘groups’);
    // exist only if you use bbPress
    bp_core_remove_nav_item(‘forums’);
    // bp_core_remove_nav_item(‘activity’);
    bp_core_remove_nav_item(‘following’);
    bp_core_remove_nav_item(‘followers’);
    bp_core_remove_nav_item(‘bookmarks’);
    bp_core_remove_nav_item(‘activity’);

    // BP’s profile main menu items. Comment those to show.
    bp_core_remove_subnav_item(‘activity’, ‘personal’);
    bp_core_remove_subnav_item(‘activity’, ‘friends’);
    bp_core_remove_subnav_item(‘activity’, ‘groups’);
    bp_core_remove_subnav_item(‘activity’, ‘following’);
    bp_core_remove_subnav_item(‘activity’, ‘feed’);
    }
    bp_core_remove_subnav_item(‘activity’, ‘mentions’);
    bp_core_remove_subnav_item(‘activity’, ‘favorites’);

    endif;
    }
    add_action(‘bp_init’, ‘bpex_hide_profile_menu_tabs’, 15);

    I have this navigation menu for the bp user on the header by default. When I am viewing other’s profiles the nav menus inside the user’s header menu also get hidden.

    Is there any other ways to do this.

    I am using the latest version of WordPress 5.4.2, BuddyPress 6.0.0, and BuddyX Theme 1.3.7.

    #311769
    bluesweet
    Participant

    I found this snippet that will remove certain tabs but it also removes the tab from the drop-down menu too. How can I just hide tabs that I don’t want the users to see on the profile page nav bar? I still want them to be seen in the dropdown menu.

    /**
    * Removing the friends tab
    */
    function mb_profile_menu_tabs(){

    global $bp;

    bp_core_remove_nav_item(‘friends’);

    }
    add_action(‘bp_setup_nav’, ‘mb_profile_menu_tabs’, 201);
    /**

    * Removing the friends tab
    */

    #309028
    Nahum
    Participant

    You might just over load members/single/parts/item-nav.php and members/single/parts/item-subnav in your child theme and just remove all the navs or replace them with something of your own.

    you could keep searching forums for topics on removing tabs there are some “solutions” to removing tabs.

    https://buddypress.org/support/search/bp_core_remove_nav_item/

    Nahum
    Participant

    What is the best way to remove user tabs? bp_core_remove_nav_item, after many years now, still doesn’t seem to be the solution. This method doesn’t only remove the link from the menu, it disables the component entirely unless I’m missing something because it seems to be offered up as the accepted solution on several threads.

    I’ve even tried

    bp_core_remove_nav_item in combo with add_action(‘bp_screens’, $screen_function) to re-add component screens >> worked somewhat but had other issues

    So I ended up with just overwriting the members/single/parts/item-nav.php file

    <nav class="<?php bp_nouveau_single_item_nav_classes(); ?>" id="object-nav" role="navigation" aria-label="<?php esc_attr_e( 'Member menu', 'buddypress' ); ?>">
    
    	<?php if ( bp_nouveau_has_nav( array( 'type' => 'primary' ) ) ) : ?>
    
    		<ul>
    
    			<?php
    			while ( bp_nouveau_nav_items() ) :
    				bp_nouveau_nav_item();
    			?>
    <?php /*///////////////////////////////////
    stopping the nav items here
    ///////////////////////////////*/?>
    
    <?php if(!in_array( bp_nouveau_get_nav_link_text(), array('Settings', 'Notifications', 'Messages')) ):?>
    
    				<li id="<?php bp_nouveau_nav_id(); ?>" class="<?php bp_nouveau_nav_classes(); ?>">
    					<a href="<?php bp_nouveau_nav_link(); ?>" id="<?php bp_nouveau_nav_link_id(); ?>">
    						<?php bp_nouveau_nav_link_text(); ?>
    
    						<?php if ( bp_nouveau_nav_has_count() ) : ?>
    							<span class="count"><?php bp_nouveau_nav_count(); ?></span>
    						<?php endif; ?>
    					</a>
    				</li>
    
    				<?php endif;?>
    
    			<?php endwhile; ?>
    
    			<?php bp_nouveau_member_hook( '', 'options_nav' ); ?>
    
    		</ul>
    
    	<?php endif; ?>
    
    </nav>
    

    What is the way to do this?

    #306086
    jennifersanchez
    Participant

    Hi.

    Im using this code to hide the tabs in the profile’s visitor

    function bpfr_hide_tabs() {
    global $bp;
    
    	
    
    	if( class_exists( 'bbPress' ) || bp_is_active ( 'groups' ) ) :
            
           
    	if ( bp_is_user() && !is_super_admin() && !bp_is_my_profile() ) {
    
          
    		bp_core_redirect( get_option('home') . '/members/' .  bp_core_get_user(). '/reviews' );
    		bp_core_remove_nav_item( 'friends' );
    		bp_core_remove_nav_item( 'groups' );
    	bp_core_remove_nav_item( 'activity' );
    	}
    	endif;
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );

    but the line
    bp_core_redirect( get_option('home') . '/members/' . bp_core_get_user( ). '/reviews' ); dont works.
    i tried with this ('BP_DEFAULT_COMPONENT','reviews'); but this dont works..

    Thanks very much!!

    #305893

    In reply to: Edit User menu

    Venutius
    Moderator

    There’s two user menu’s, there’s the profile pages themselves – these are created and removed using the pfp functions bp_core_new_nav_item and bp_core_remove_nav_item.

    Then there’s the WP Admin menu that drops down fron the top right hand side of the screen, these items are created and deleted by manipulating the $wp_admin_bar global variable.

    If you search these forums for any of those terms you should find examples of how these are used.

    #305549
    polywebjeff
    Participant

    Switching to the default aarvark theme did indead remove the error messages. I’ve switched back to the child theme, and removed mycode from bp-custom. No results. My BP templates do not contain bp_nav, but I didn’t took the time to change the file versions in the top comments. I have those custom files:

  • aarvark-child/buddypress/members/single/myorganization/edit.php
  • /**
     * BuddyPress - Members Single Profile Edit
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/myorganization/profile-loop.php
  • /**
     * BuddyPress - Members Profile Loop
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/myorganization/profile-wp.php
  • /**
     * BuddyPress - Members Single Profile WP
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/profile/edit.php
  • /**
     * BuddyPress - Members Single Profile Edit
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     * @version 3.0.0
     */
  • aarvark-child/buddypress/members/single/home.php
  • /**
     * BuddyPress - Members Home
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     */
  • aarvark-child/buddypress/members/single/member-header.php
  • /**
     * BuddyPress - Users Header
     *
     * @package BuddyPress
     * @subpackage bp-legacy
     */
  • aarvark-child/buddypress/members/register.php
  • no version in comments

    In my functions.php file:

    // New buddypress nav items
    
    function add_bp_menu_items() {
        global $bp;
        //Remove unwanted nav items
        bp_core_remove_nav_item( 'activity' );
        bp_core_remove_nav_item( 'forums' );
        bp_core_remove_nav_item( 'user-media' );
    //    bp_core_remove_subnav_item( 'profile', 'public' );
        unset($bp->bp_options_nav['profile']['public']);
        unset($bp->bp_options_nav['profile']['change-avatar']);
        unset($bp->bp_options_nav['profile']['change-cover-image']);
        unset($bp->bp_options_nav['settings']['profile']);
        unset($bp->bp_options_nav['settings']['data']);
    
        $bp->bp_options_nav['profile']['name'] = 'My Profile';
    }
    add_action( 'bp_setup_nav', 'add_bp_menu_items', 15 );
    
    // Change Profile menu/tab order
    function rt_change_profile_tab_order() {
        global $bp;
    
        $bp->members->nav->edit_nav( array(
            'name' => 'My Profile',
        ), 'profile' );
    
        $bp->members->nav->edit_nav( array(
            'position' => 1,
        ), 'profile' );
    
        $bp->members->nav->edit_nav( array(
            'position' => 65,
        ), 'notifications' );
    }
    add_action( 'bp_init', 'rt_change_profile_tab_order', 999 );
#303745
Venutius
Moderator

Here’s how to remove forums from all users profile tabs and toolbar menu, this code would need to go in your child-themes functions.php:

function venutius_remove_forums_on_usermenu() {
global $wp_admin_bar;

	if ( bp_use_wp_admin_bar() ) {
		$wp_admin_bar->remove_node( 'my-account-forums' );
	}

}
add_action( 'wp_before_admin_bar_render', 'venutius_remove_forums_on_usermenu' );

function venutius_remove_profile_forums_tab() {

	bp_core_remove_nav_item( 'forums' );

}
add_action( 'bp_actions', 'venutius_remove_profile_forums_tab' );
#278492
John
Participant

I’m trying to create an entirely custom buddypress member profile page.

Have worked out the template overrides for the header and main body (front.php, member-header.php) but can’t work out how to override the member primary navigation menu.

I know I can get rid of individual items with

bp_core_remove_nav_item( 'forums' );

but what I want to do is get rid of the entire menu as it’s not required.

Anyone know how to do this?

Thanks!

#276789
jonimueller
Participant

With the help of this forum, I was able to solve part of an issue. We don’t want unapproved members sending messages to other registered members until they are approved. I found some code here that does this exact thing:

    if ( ! $unapproved_member ) {
        bp_core_remove_nav_item( 'friends' ); //removes the tab friends
        bp_core_remove_nav_item( 'messages' ); //removes the tab messages
        bp_core_remove_nav_item( 'reviews' ); //removes the tab reviews
    }

}

However, in place of those tabs’ content, is a 404 page. I’d prefer a 403 page in its place. Any thoughts as to how to accomplish this?

Or in the alternative, to redirect each of those tabs to one page explaining the disablement of a large portion of the site until they are approved?

#274735
Henry Wright
Moderator

I can’t find bp_activity_setup_nav in the current codebase. Hooking to bp_init instead should work.

bp_core_remove_nav_item() will delete an item from the primary navigation of the specified component.

bp_core_remove_subnav_item() will delete an item from the secondary navigation of the specified component.

Hope this helps.

#274682
ghosted
Participant

BuddyPress :3.1

I really hope someone can help me with this. I’ve read a lot of support pages/articles from varying sources, nothing I put in bp-custom.php works for removing profile nav tabs/sub nav tabs.

I’ve already tried https://buddypress.org/support/topic/the-right-way-to-remove-nav-items/

Is it possible to make Activity and Forum profile tabs private?


which doesn’t seem to have any effect at all.

the only thing i’ve found that kind does anything is:

function bp_remove_activity_from_profile()
{
bp_core_remove_nav_item('activity');
}
add_action('bp_activity_setup_nav','bp_remove_activity_from_profile');

but it’s not ideal since there are quite a few things i’d like to remove.

#272624
panosa1973
Participant

@venutius you were right on the money! This worked. Now a member can see their Friends menu item even when they’re on another member’s profile but without having access to the other member’s friends. And you said it was gonna be difficult. Hah! 🙂
Thank you yet again!

function hide_friends_tab() {
	global $bp;
	if ( !bp_is_my_profile() && !is_super_admin() ) {
		bp_core_remove_nav_item( 'friends' ); 

		bp_core_new_nav_item( 
    	        array( 
                'name' => __('Friends', 'buddypress'), 
                'slug' =>  $bp->friends->slug, 
                'position' => 50, 
                'show_for_displayed_user' => false,
                'default_subnav_slug' => 'friends'
    ));
	
	}
}
add_action( 'bp_setup_nav', 'hide_friends_tab', 15 );
#272510
panosa1973
Participant

Hi @venutius. This works the same as my code. Say I’m a regular member viewing another member’s profile. The issue is that when it detects that it’s not my profile page and it removes the other member’s Friends tab, it also removes my own Friends menu item from my Main Menu. So basically when I’m viewing someone else’s profile, I don’t have the link to my main menu to visit my own Friends page because bp_core_remove_nav_item( 'friends' ); removes that too.

#272497
panosa1973
Participant

WordPress 4.9.5 -> BuddyPress 2.9.4 -> Agama Blue Child Theme

I ended up with the below code from posts in these forums but it doesn’t do quite what I need it to do.
Users should not be able to see other users’ friends so the Friends tab when viewing another user’s profile page must be removed along with the functionality. Here’s my code:

function bpfr_hide_tabs() {
	if ( !is_super_admin() && !bp_is_my_profile() ) {
		bp_core_remove_subnav_item( 'profile', 'friends' );  // This does nothing
		//bp_core_remove_nav_item( 'friends' );  //Or this but this also hides the Friends main menu item, not just the Friends tab in the user's profile page 
	}
}
add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );

I’ve switched between both options in the code. bp_core_remove_subnav_item( 'profile', 'friends' ); doesn’t really do anything and bp_core_remove_nav_item( 'friends' ); does remove the Friends tab from another user’s profile but it also removes it from the main menu which is a different thing. The main menu Friends link points to my own Friends whereas the Friends tab in another user’s profile points to their friends. Any help would be appreciated.

#272407
Varun Dubey
Participant

@panosa1973
First sub nav points to the primary tab for all core tabs

To remove sub nav you can use the following approach, but it will not work for first sub nav like the view

// remove nav forums and coures 
function bb_remove_extra_tab() { 
     global $bp;      
bp_core_remove_nav_item( 'friends' );   
bp_core_remove_subnav_item( 'profile', 'edit' );
} 
add_action( 'bp_actions', 'bb_remove_extra_tab', 999 );
#272402
panosa1973
Participant

WordPress 4.9.5 -> BuddyPress 2.9.4

Hi all,
This is when viewing a user’s profile page. I removed the Friends tab with the below code but the View tab is still showing (it’s not necessary since the Profile tab is there and points to the same place, the user’s profile page). Is there a list somewhere of the slugs for the tabs or is there a function that can generate that? Or am I completely off about this 🙂
Thanks in advance.

function remove_nav_items() {
if ( !bp_is_my_profile() && !is_super_admin()) {
bp_core_remove_nav_item( 'friends' );
bp_core_remove_nav_item( 'view' );
}
}
add_action( 'bp_setup_nav', 'remove_nav_items',301);

#270600
chrishustert
Participant

Thanks David, but I have found another cool solution. It’s not Pet Owner and Pet Groomer anymore though.
Hope it helps other people, too!


**
 * Remove certain tabs from user profile based on member role.
 */
function buddydev_remove_tabs_based_on_member_roles() {
	if ( ! bp_is_user() ) {
		return;
	}
    
    $premium_dog_owner = bp_current_user_can( 'premium_dog_owner' );
    $premium_dog_borrower = bp_current_user_can( 'premium_dog_borrower' );
    
    $premium_user = ($premium_dog_owner ? : $premium_dog_borrower);
    
    if ( ! $premium_user ) {
        bp_core_remove_nav_item( 'friends' ); //removes the tab friends
        bp_core_remove_nav_item( 'messages' ); //removes the tab messages
        bp_core_remove_nav_item( 'reviews' ); //removes the tab reviews
    }

}

add_action( 'bp_setup_nav', 'buddydev_remove_tabs_based_on_member_roles', 1001 );
#270564
keshabee
Participant

Good Afternoon, I wanted to ask if there was any-one who has an ides how to hide site > my site which is created by buddypress on the admin dashboard area. as below
https://postimg.org/image/dop3730kl/

As i was able to find a way to hide the site from the user profile thanks to @vapvarun
using the function

function vap_remove_buddypress_sites_tabs() {
	global $bp;
       // to remove main menu for sites.
       bp_core_remove_nav_item('blogs' );
}
add_action( 'bp_setup_nav', 'vap_remove_buddypress_sites_tabs', 999 );

But the question is how do i hide it also in the admin dashboard.
As preferable I would likely wish if i could hide it specifically from other users except admin and site owner.
Thank you in advance

#270434
katmacau
Participant

It was some code in a plugin that was deprecated. The solution was to replace with this:


function bpcodex_remove_member_notifications_tab() {
bp_core_remove_nav_item( ‘notifications’ );
}
add_action( ‘bp_actions’, ‘bpcodex_remove_member_notifications_tab’ );
#270414
David Cavins
Keymaster

I’m note sure how your custom roles were created, so I can’t tell you how to figure out if the current user is one or the other, but basically, you’ll be using code like this:


function bpcodex_remove_member_tab_on_role() {
  $role = 'owner;
  if ( 'owner' == $role ) {
	bp_core_remove_nav_item( 'messages' );
	bp_core_remove_nav_item( 'friends' );
  }
}
add_action( 'bp_actions', 'bpcodex_remove_member_tab_on_role' );

note that this will not work as is–you need to be able to get the current user’s role, dependent on how you’re doing that. However, the simpler answer is that if you’re not using the friends and messages components, just turn them off in the BuddyPress settings in wp-admin.

#270409
David Cavins
Keymaster

Hi @katmacau-

Here are some examples for changing navigation menus using the new API:

Navigation API

This is what I’m guessing you’ll want to use:


function bpcodex_remove_member_notifications_tab() {
	bp_core_remove_nav_item( 'notifications' );
}
add_action( 'bp_actions', 'bpcodex_remove_member_notifications_tab' );

One question though: if you’re not using the notifications, why not just turn off the notifications component in the BuddyPress settings screen in wp-admin?

Viewing 25 results - 1 through 25 (of 157 total)
Skip to toolbar