Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_remove_nav_item'

Viewing 25 results - 26 through 50 (of 119 total)
  • Author
    Search Results
  • #270070
    shayne
    Participant

    I want to remove certain navigation items from user profiles.

    However if I use this line, it also removes them from the main menu.

    bp_core_remove_nav_item( 'settings' );

    I need the items on the main menu, but i want them removed from the user profile.

    Anyway to do that?

    #270057
    Varun Dubey
    Participant

    @brunothomas You can try following codes to remove any specific tabs and subtabs

    function vap_remove_buddypress_profile_tabs() {
    	global $bp;
           // to remove main menu like friends.
           bp_core_remove_nav_item('friends' );
           // to remove sub nav favorites under activity.
           bp_core_remove_subnav_item('activity', 'favorites');
    }
    add_action( 'bp_setup_nav', 'vap_remove_buddypress_profile_tabs', 999 );

    To create new tabs, you will have to create dedicated functions

    Custom Member Tab

    #268904
    autox420
    Participant

    Found a solution.

    functions.php

    if( !defined( 'BP_DEFAULT_COMPONENT' ) ){
        define( 'BP_DEFAULT_COMPONENT', 'profile' );
    }
    function bp_remove_profile_tab_activity(){
       bp_core_remove_nav_item( buddypress()->activity->id );
    }
    add_action( 'bp_setup_nav', 'bp_remove_profile_tab_activity', 999 );
    #268699
    MSoliman
    Participant

    I’m using these code to hide taps for non friends members , the problem is . i need to hide the activity tap for non friends .. but without changing the default landing tab for the profile owner .. i want to dynamically set the landing tab for non friends to “profile” .. and for the profile owner to “activity”

    //remove profile tabs for non friends members//
    		function bpfr_maybe_hide_friends_nav_etc() {
    			$retval = false;
    			// condition 
    			if ( bp_is_user() && ! bp_is_my_profile() && ! friends_check_friendship( bp_displayed_user_id(), bp_loggedin_user_id() ) ) {
    				
    				$retval = true;
    			}	
    			return $retval;
    		}
    
    		function bpfr_hide_friends_nav_to_non_friends() {	
    			// stop if condition is not ok
    			if ( ! bpfr_maybe_hide_friends_nav_etc() ) {
    				return;
    			}
    			// otherwise we remove the nav items
    			// bp topnav items
    			
    			bp_core_remove_nav_item( 'groups' );
    			bp_core_remove_nav_item( 'activity' );
    			bp_core_remove_nav_item( 'events' );
    			bp_core_remove_nav_item( 'media' );
    			bp_core_remove_nav_item( 'profile' );
    			bp_core_remove_nav_item( 'friends' );
    			//bp subnav items
    			bp_core_remove_subnav_item( 'activity', 'friends' ); 
    			bp_core_remove_subnav_item( 'activity', 'mentions' ); 
    			
    		}
    		add_action( 'bp_ready', 'bpfr_hide_friends_nav_to_non_friends' );
    tisor
    Participant

    I had a site plugin, disabling the menu options for WordPress. Using this code:

    bp_core_remove_nav_item( ‘settings’ );

    This was generating the 404. Removed it, all worked.

    manm0untain
    Participant

    Hi Everyone

    I have been struggling with this for a few weeks now. I’m hoping someone can help out.

    So the main profile menu on the Buddypress profile / member area (activity/profile/friends/groups/forum etc). I need to remove some of those items.

    Some items (e.g. forum) I need to remove from there because I only want to have forums in groups, not a central forum. So I need to retain the forum functionality, just not have that link on the user areas.

    Other items I don’t need because I have already set them up on the site main navigation at the top Facebook style (e.g. messages, notifications, settings) and no need to duplicate them on the Buddypress member area menu.

    I have tried using CSS, however this retains the links to the items in the page source. So this is not ideal.

    I have tried using jQuery – same results as CSS.

    I have tried using unset – but this actually removes the functionality, not just the links on the member area nav.

    I have tried using bp_core_remove_nav_item. However this has some side effects. The links to the user messages / notifications / settings at the top of the site are created from the Buddypress options under Appearance > Menus. It seems when you remove those items using bp_core_remove_nav_item, it removes them from the top too. I only want to remove them from the Buddypress member area navigation bar.

    I tried to be clever, and recreated those top menu items using a shortcode to the appropriate user. The links are there and correct. However, one bp_core_remove_nav_item is added – it also seems to disable the various functionality. So now if I go to messages for example, I just get a 404 page. Remove the bp_core_remove_nav_item function and the page / link works correctly again. So it seems bp_core_remove_nav_item is actually removing the functionality of the items on the nav, instead of removing a navigation item, that the function name kind of suggests.

    I can’t recreate that menu manually with HTML, because remaining items (e.g. Media, Groups, Friends etc) have a little dynamic number to the side of each icon indicating how many items are in that area.

    Can anyone please give me some pointers as to how I might remove some items just from that Buddypress member area navigation bar – without leaving links in source code, without removing ALL instances of navigation to those items, and without removing the actual functionality?

    I’m happy to hack the hell out of the core files if needed, I just can’t seem to find anywhere where I might be able to make that change.

    Any help with this would be greatly appreciated, many thanks.

    #264188
    083n
    Participant

    I solved it with my own effort.

    function bp_remove_nav_item() {
        $current_user   = wp_get_current_user();
        $role_name      = $current_user->roles[0];
        if($role_name==='administrator'){
           bp_core_remove_nav_item( 'buddyblog' );
        }
    }
    add_action( 'wp', 'bp_remove_nav_item' );

    This code delete blog menu for administrator.

    #262747

    I think you’ll want something like this:

    add_action( 'bp_actions', 'remove_members_activity_tab', 5 );
    function remove_members_activity_tab() {
    	global $bp;
    	bp_core_remove_nav_item( 'activity' );
    }

    which should remove the tab, but it’ll also remove the whole navigation if Activity is set as the default. To make sure that doesn’t happen, add this:

    add_action( 'bp_setup_nav', 'change_settings_subnav', 5 );
    function change_settings_subnav() {
    	$args = array(
    		'parent_slug' => 'settings',
    		'screen_function' => 'bp_core_screen_notification_settings',
    		'subnav_slug' => 'notifications'
    	);
    
    	bp_core_new_nav_default( $args );
    }
    #262492
    Laura N
    Participant

    If you add in functions.php this code

    
    function remove_nav_items() {
        bp_core_remove_nav_item( 'forums' );
    }
    add_action( 'bp_setup_nav', 'remove_nav_items',301);

    You can remove the forum options in horizontal menu, but in vertical menu (profile user) no.

    I am trying it with css, but it is impossible

    li#wp-admin-bar-my-account-social-forums.menupop {display:none !important;}

    #262457
    Laura N
    Participant

    O_o it is very difficult for me, but “activity” was just an example, If I want to remove a no default option? For example “docs”.

    In my buddypress show “docs” because I installed BuddyPress Docs plugin.

    function bpfr_remove_nav_tabs() {
    
    	bp_core_remove_nav_item( 'docs' ); 
       // and so on for each item you want to remove
    
    }
    add_action( 'bp_setup_nav', 'bpfr_remove_nav_tabs', 15 );
    #262447
    Laura N
    Participant

    Yes, It´s true, I am sorry

    I have created the bp-custom.php inside plugin folder.

    then I have added this code between php

    function bpfr_remove_nav_tabs() {
    
    	bp_core_remove_nav_item( 'activity' ); 
       // and so on for each item you want to remove
    
    }
    add_action( 'bp_setup_nav', 'bpfr_remove_nav_tabs', 15 );

    But the activity options is visible 🙁

    #261275
    shanebp
    Moderator

    Did you try:

    function cs_remove_friends_nav() {
       bp_core_remove_nav_item( bp_friends_slug() );
    }
    add_action( 'bp_setup_nav', 'cs_remove_friends_nav' );
    danbp
    Participant

    @fearthemoose, @rezbiz,

    Here “the best guarded secret” finally revealed !
    But it’s not a secret, is part of Codex and a multi handled topic subject on this forum.

    What we want to do: remove access possibility.
    Where: on BuddyBar navigation menu (the one below the profile header).
    Specifics: make the activity and forum tabs only visible to the logged in user.

    NOTE: The activity tab is shown by default when you visit a profile.

    As we are going to hide/remove this tab to visitors, we need to define as first another default tab. If we won’t do that, the visitor will get a Page not found error. Which is not exactly the case here, the page exist but the visitor can’t access it.

    Let’s define arbitrary Profile as the new default tab. You can of course define what ever other existing tab on your BuddyBar as default.

    Add this line to bp-custom.php
    define( 'BP_DEFAULT_COMPONENT','profile' );

    Now the mega “open secret” !

    The folowing snippet contains almost any BP menu items you can have on a BuddyBar, and includes also the Forum item, in case you use bbPress.
    You can remove or comment out those you don’t want to use.
    Note also that it is only an example – you have to play with it to fit your need. But at least you have the right syntax to use.
    Note also that some profile menu items are user only, such as message or notice. In other words, these are always private.

    This function goes preferably to bp-custom.php

    function bpfr_hide_tabs() {
    global $bp;
    	 /**
    	 * class_exists() & bp_is_active are recommanded to avoid problems during updates 
    	 * or when Component is deactivated
    	 */
    
    	if( class_exists( 'bbPress' ) || bp_is_active ( 'groups' ) ) :
            
            /** here we fix the conditions. 
            * Are we on a profile page ? | is user site admin ? | is user logged in ?
            */
    	if ( bp_is_user() && !is_super_admin() && !is_user_logged_in() ) {
    
            /* and here we remove our stuff ! */
    		bp_core_remove_nav_item( 'activity' );
    		bp_core_remove_nav_item( 'friends' );
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'forums' );
    	}
    	endif;
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );

    Some other hints for privacy
    if you want to allow only the profile owner to view some tabs, replace
    !is_user_logged_in by !bp_is_my_profile() – this scenario doesn’t need a check for logged in users as it is made by bp_is_my_profile.

    If you want only to make a profile private, read here.

    If you want to remove a sub-nav item (ie. View on Profile), you use something like:
    bp_core_remove_subnav_item( 'profile', 'view' );

    Many other possibilities for navigation are also available, including for groups. Several examples are given on Codex, here.

    And if not enough, RTFM and search the forum ! 🙂

    Have fun !

    #258720
    SrGato29
    Participant

    Hi there ,

    Thanks for your response, I tried your function, but without success, I try this function which I found on internet

    function my_remove_em_nav() {
    	global $bp;
          bp_core_remove_nav_item( 'settings' );
       
    
    }
    add_action( 'bp_init', 'my_remove_em_nav' );

    Thanks

    #258702
    modemlooper
    Moderator

    If you remove settings tab it auto removes all child pages.

    function w24dr_remove_settings_nav() {
          bp_core_remove_nav_item( bp_settings_slug() );
       }
    add_action( 'bp_setup_nav', 'w24dr_remove_settings_nav' );
    #258440
    danbp
    Participant

    Perhaps check for quotes ? You use instead '

    The snippet will work by changing them.

    define( 'BP_DEFAULT_COMPONENT', 'profile' ); // Triem nova pestanya per defecte
    
    function bphelp_remove_activity_from_profile(){
    
    bp_core_remove_nav_item('activity');
    }
    add_action('bp_activity_setup_nav','bphelp_remove_activity_from_profile');
    #258342
    Fantacular Designs
    Participant

    My brilliant husband is my coder… He figured out how to define the default component, and saved the day. I hope this helps others.

    define( 'BP_DEFAULT_COMPONENT', 'profile' );
    
    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'activity');
    		bp_core_remove_nav_item( 'notifications');
    		bp_core_remove_nav_item( 'messages' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'settings' );
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    #258234
    Fantacular Designs
    Participant

    I also attempted to add them individually…

    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'activity' );
    		bp_core_remove_nav_item( 'notifications' );
    		bp_core_remove_nav_item( 'messages' );
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_nav_item( 'settings' );
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    

    I’ve noticed some changes require us to repeat ourselves, while others allow us to list changes within one line of code. Haven’t deciphered this anomaly just yet.

    #258232
    Fantacular Designs
    Participant

    I placed the following code in the bp-custom.php which was found under the wp-content -> plugins.

    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'notifications', 'activity', 'groups', 'messages', 'forums', 'settings');
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    

    It breaks my site, shuts it down. From what I’ve read, I am supposed to specify what tab is open when opening a profile. Otherwise, browsers don’t know what to display since default is “Activity” and I’m removing it… Can someone please tell me where I went wrong? I appreciate the help!

    #258094

    In reply to: New Privacy Plugin

    danbp
    Participant

    hi @fencer04,

    thank for sharing your work. Well done, but it needs some revision (sorry).
    At his activation on 2 test sites (one with 4.5.3/bp 2.6.1, other 4.6/bp2.6.2) i got a notice.
    Array to string conversion in buddypress/bp-core/classes/class-bp-core-nav.php on line 279from

    sbpp04_privacy_check( )	..\plugin.php:525
    sbpp04_privacy_redirect( )	..\buddypress-profile-privacy.php:176
    bp_core_remove_nav_item( )	..\buddypress-profile-privacy.php:184
    BP_Core_Nav->delete_nav( )	..\bp-core-buddybar.php:798

    Another point concerning UI/UX is the Private button appearing on buddybar.
    On this tab, a default message says Friends Only.
    USERNAME has chosen to limit profile access to friends only.
    That’s wrong! Because this appear on each profile, even if the owner hasn’t setup anything about his profile privacy.

    So far i understand its fonctionality, this plugin let each member decide to show or not his whole profile page to friends or members only or to everyone (bp default).

    – imo this tab should show “This profile is private” to anybody who is concerned by a privacy setting and should not appear at all if “Everyone” is set.
    – the original BP Add as friend button on profile header or members directory is still there. This means that there is no need to go on Private tab to ask forfriendship.
    This is a little confusing !

    If the plugin is to extend profile settings, it should appear in profile settings only. And as it doesn’t superseed BP, there is no real reason to give him an extra tab on buddybar outside of the settings scope. A template notice could be enough to tell visitors what’s going on on such a profile.

    Just my 2 cents.

    #257327
    danbp
    Participant

    Hi,

    two snippets to remove profile and group items.

    function bpex_hide_profile_menu_tabs() {
    
    	if( bp_is_active( 'xprofile' ) ) :
    
    	if ( bp_is_user() && !is_super_admin() && !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's profile main menu items. Comment those to show.
    	//	bp_core_remove_subnav_item( 'activity', 'personnal' );
    		bp_core_remove_subnav_item( 'activity', 'mentions' );
    		bp_core_remove_subnav_item( 'activity', 'favorites' );
    		bp_core_remove_subnav_item( 'activity', 'friends' );
    		bp_core_remove_subnav_item( 'activity', 'groups' );
    	}
    	endif; 
    }
    add_action( 'bp_setup_nav', 'bpex_hide_profile_menu_tabs', 15 );
    
    function bpex_remove_group_tabs() {  
    
    	if ( ! bp_is_group() ) {
    		return;
    	}
    
    	$slug = bp_get_current_group_slug();
    
    		// hide items to all users except site admin
    	if ( !is_super_admin() ) {
    
    	//	bp_core_remove_subnav_item( $slug, 'members' );
    		bp_core_remove_subnav_item( $slug, 'send-invites' );
    	//	bp_core_remove_subnav_item( $slug, 'admin' );
    	//	bp_core_remove_subnav_item( $slug, 'forum' );
    	}
    
    }
    add_action( 'bp_actions', 'bpex_remove_group_tabs' );
    #256411
    danbp
    Participant

    Add this snippet to bp-custom.php and give it a try.

    function bpex_hide_profile_menu_tabs() {
    
    	if( bp_is_active( 'xprofile' ) ) :
    
    	if ( bp_is_user() && !is_super_admin() && !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's profile main menu items. Comment those to show.
    	//	bp_core_remove_subnav_item( 'activity', 'personnal' );
    		bp_core_remove_subnav_item( 'activity', 'mentions' );
    		bp_core_remove_subnav_item( 'activity', 'favorites' );
    		bp_core_remove_subnav_item( 'activity', 'friends' );
    		bp_core_remove_subnav_item( 'activity', 'groups' );
    	}
    	endif;
    }
    add_action( 'bp_setup_nav', 'bpex_hide_profile_menu_tabs', 15 );
    #256031
    javierllinas
    Participant

    Hello,

    Working perfect for subnav items, but not for main nav in my case. Can’t get this to work:

    function my_remove_group_tab() {
    
        bp_core_remove_nav_item( 'send-invites', 'groups' );
    
    }
    add_action( 'bp_actions', 'my_remove_group_tab', 9 ); 

    I don’t now what I’m missing here.

    Appreciate any help.

    #255297
    javierllinas
    Participant

    Thanks, @danbp!

    You are right: only the fallback was working bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );.
    Adding the $component (which defaults to ‘members’) is the key:

    bp_core_remove_subnav_item( $parent_nav_slug, $tab, 'groups' );

    These functions are located in ‘bp-core/bp-core-buddybar.php’.
    I’d also want to get rid of ‘send-invites’ in group primary navigation, but this is not working for me:

    bp_core_remove_nav_item( 'send-invites', 'groups' );

    Thank you,
    Javier

    #255125
    sharmavishal
    Participant

    try this and let me know if it works in bp 2.6 for u or not

    function my_remove_em_nav() {
    	global $bp;
          bp_core_remove_nav_item( 'events' );
          bp_core_remove_subnav_item( 'settings', 'profile' );
    
    }
    add_action( 'bp_init', 'my_remove_em_nav' );
Viewing 25 results - 26 through 50 (of 119 total)
Skip to toolbar