Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'bp_core_remove_nav_item'

Viewing 25 results - 26 through 50 (of 154 total)
  • Author
    Search Results
  • #270002
    ingohaeck
    Participant

    For privacy issues I want to hide certain links on profile view.
    i use the snippet, mentioned here (see script below):
    one

    This works fine with BP related links, but I cannot hide links from CPT like rtMedia and the link of this:

    `function bp_postsonprofile() {
    add_action( ‘bp_template_content’, ‘profile_screen_posts_show’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }

    function profile_screen_posts_show() {

    $myposts = get_posts( array(
    ‘posts_per_page’ => -1,
    ‘author’ => bp_displayed_user_id(),
    ‘post_type’ => ‘post’
    ));

    if( ! empty($myposts) ) {

    echo ‘<ul>’;

    foreach($myposts as $post) {
    setup_postdata( $post );
    echo ‘<li><a href=”‘ . get_permalink($post->ID) . ‘”>’ . get_the_title($post->ID) . ‘</a></i>’;
    }

    echo ‘</ul>’;

    wp_reset_postdata();

    } else {

    echo ‘<div class=”info” id=”message”><p>’. bp_displayed_user_fullname() .’ hat keine Beiträge veröffentlicht.</p></div>’;
    }
    }

    add_action ( ‘profile_screen_posts_show’ );`

    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( ‘posts’ );
    bp_core_remove_nav_item( ‘forums’ );
    bp_core_remove_nav_item( ‘media’ );
    }
    endif;
    }
    add_action( ‘bp_setup_nav’, ‘bpfr_hide_tabs’, 15 );

    #269870
    seanbees
    Participant

    I currently used this method first, which wasn’t working for me:

    $bp->bp_nav['settings'] = false;

    Then I used this snippet instead, which happened to work, but unfortunately removed the nav items from my main menu as well instead of just the BuddyPress profile fields:

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

    Any idea on how to make it so it only removes the items from the profile fields rather than all the nav menus in general?

    HDcms
    Participant

    Hello,
    How to hide the button “Members” in the display of a group?
    https://screenshots.firefox.com/4fhh6NF0U12mYFQu/null

    The following code does not work:

    function bpex_hide_members_menu_tabs() {
    	if ( bp_is_group() ) {
    	if ( is_super_admin() ) 
     	return ;
    		bp_core_remove_nav_item('members');
    	}
    }

    Regards

    #269570

    Hello!

    I moved the “Change avatar” and “Change cover” subnavs from the tab “Profile” to “Setting”. It works good, but no content is displayed … I don’t know why, because the function “xprofile_screen_change_avatar” is triggered.

    Does anybody has an idea?

    Here is my code from the functions.php:

    
    function custom_bp_menu_tabs() {
        global $bp;
    
        if ( bp_is_active( 'xprofile' ) ):
            $change_avatar = $bp->bp_options_nav['profile']['change-avatar']->backcompat_nav;
    
            if ( ! empty( $change_avatar ) ) {
                $change_avatar['parent_slug'] = $bp->bp_nav['settings']['slug'];
                $change_avatar['parent_url']  = $bp->loggedin_user->domain . $bp->bp_nav['settings']['slug'] . '/';
                unset( $change_avatar['link'] );
    
                bp_core_remove_subnav_item( $bp->bp_nav['profile']['slug'], $change_avatar['slug'] );
                bp_core_new_subnav_item( $change_avatar );
            }
    
            bp_core_remove_nav_item( 'profile' );
    
            bp_core_remove_subnav_item( $bp->bp_nav['settings']['slug'], 'notifications' );
            bp_core_remove_subnav_item( $bp->bp_nav['settings']['slug'], 'profile' );
        endif;
    }
    
    add_action( 'bp_setup_nav', 'custom_bp_menu_tabs', 9999 );
    
    #269320
    HDcms
    Participant

    Hello,

    There are many examples to hide the navigation on a profile bp_core_remove_nav_item(‘friends’ );.
    How to hide tabs on the Sitewide Activity page ?

    Regards

    #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
    moefahmy
    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.

    meganme517
    Participant

    I got rid of the profile tab with this:

    function bphelp_remove_activity_from_profile(){
    bp_core_remove_nav_item(‘activity’);
    }
    add_action(‘bp_activity_setup_nav’,’bphelp_remove_activity_from_profile’);

    I can’t figure out how to remove friends and messages. I have tried this which doesn’t work:

    function bphelp_remove_friends_nav() {
    bp_core_remove_nav_item( bp_friends_slug() );
    }
    add_action( ‘bp_setup_nav’, ‘bphelp_remove_friends_nav’ );

    Any suggestions?

    #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.

    #264187
    083n
    Participant

    I need to show BuddyPress menu item just specific roles and hide all other users.
    I have 2 user roles like subscriber and author.
    For example; I want to show my friends only to the authors and to me. None of the other subscribers can see.

    I can hide menu items with this code in functions.php ;

    function bp_remove_nav_item() {
        global $bp;    
        bp_core_remove_nav_item( 'buddyblog' );
        }
    add_action( 'wp', 'bp_remove_nav_item' );

    How can I edit this for excepting to me and the authors ?

    Strothi
    Participant

    Hey guys,

    first of all, awesome forum! I’ve already solved so many of my issues simply by reading the many helpful answers – hence never had the need to post anything myself, but now I’m a bit stuck.

    Here’s what I wanted to do: Put a new profile group in a separate bp profile menu tab and make it visible to both, logged in as well as logged out users. Now, it works perfectly fine, except for the fact that logged out users for some reason get to see my personal profile group under my custom tab instead of the new profile group – which is displayed correctly for me as well as other logged in users.

    Here’s my code:

    /**
    BP Profile Tab Visibility
    */
    
    function bpfr_hide_top_nav() {	
    	
    	if( !is_user_logged_in() ) {	
    
    // bp topnav items to hide	
    		bp_core_remove_nav_item( 'activity' );			
    		bp_core_remove_nav_item( 'friends' );
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_nav_item( 'media' );
    		bp_core_remove_nav_item( 'docs' );
    		bp_core_remove_nav_item( 'location' );
    	
    
    //bp subnav (my activities, my groups, etc)
    		bp_core_remove_subnav_item( 'activity', 'activity' );
    		bp_core_remove_subnav_item( 'activity', 'friends' ); 
    		bp_core_remove_subnav_item( 'activity', 'favorites' );
    		bp_core_remove_subnav_item( 'activity', 'groups' );
    		bp_core_remove_subnav_item( 'activity', 'mentions' );
    		bp_core_remove_subnav_item( 'activity', 'media' );
    		bp_core_remove_subnav_item( 'activity', 'docs' );
    		bp_core_remove_subnav_item( 'activity', 'comments' );
    
    	}
    }
    add_action( 'bp_ready', 'bpfr_hide_top_nav', 10 );
    
    /**
    BP Tab Order Profile and Tab Rename
    */
    
    function bpex_primary_nav_tabs_position() {
    	buddypress()->members->nav->edit_nav( array( 'position' => 2,	), 'activity' 		);
    	buddypress()->members->nav->edit_nav( array( 'position' => 1, 	), 'profile' 		); 
    	buddypress()->members->nav->edit_nav( array( 'position' => 3,	), 'messages' 	  	);
        buddypress()->members->nav->edit_nav( array( 'position' => 4, 	), 'notifications'	); 
    	buddypress()->members->nav->edit_nav( array( 'position' => 5,	), 'friends' 	  	);
    	buddypress()->members->nav->edit_nav( array( 'position' => 6,	), 'groups' 		);
    	buddypress()->members->nav->edit_nav( array( 'position' => 7, 	), 'forums' 		);
        buddypress()->members->nav->edit_nav( array( 'position' => 8, 	), 'criticalreview'	);
    	buddypress()->members->nav->edit_nav( array( 'position' => 9, 	), 'docs' 		    );
        buddypress()->members->nav->edit_nav( array( 'position' => 10, 	), 'media'	     	);
        buddypress()->members->nav->edit_nav( array( 'position' => 11, 	), 'location'     	);
        buddypress()->members->nav->edit_nav( array( 'position' => 12, 	), 'orders'	     	);
        buddypress()->members->nav->edit_nav( array( 'position' => 13, 	), 'settings' 		);
    }
    add_action( 'bp_setup_nav', 'bpex_primary_nav_tabs_position', 999 );
    
    /**
    Put Critical Review Profile Group in BP Tab
    */
    
    function buddydev_modifyy_user_profile_tab() {
    
    bp_core_new_nav_item( array(
    'name'	=> 'Critical Review',
    'slug'	=> 'criticalreview',
    'screen_function'	=> 'buddydev_screen_profile_data',
    'default_subnav_slug' => 'criticalreview-sub',
    'show_for_displayed_user' => true,
    ));
    
    }
    add_action( 'bp_setup_nav', 'buddydev_modifyy_user_profile_tab', 8 );
    
    function buddydev_screen_profile_data() {
    //filter loop
    add_filter( 'bp_after_has_profile_parse_args', 'buddydev_filter_args_for_profile_group' );
    //load loop
    add_action( 'bp_template_content', 'buddydev_show_profile_group_data');
    
    bp_core_load_template( 'members/single/plugins');
    }
    
    function buddydev_filter_args_for_profile_group( $args ) {
    ///CHANGE IT
    $args['profile_group_id'] = '6'; //Your Profile Group ID Here
    
    return $args;
    }
    //Load the loop 
    function buddydev_show_profile_group_data() {
    $profileslug = bp_get_profile_slug();
    // if ( bp_is_my_profile() ) :
    // echo "Edit under Profile";
    // endif;
    bp_get_template_part( 'members/single/profile/profile-loop' );
    }
    
    function hide_profile_group( $grpid ) {
    if ( is_user_logged_in() && !bp_is_profile_edit() ) {
    $myfield = xprofile_get_field_data( 'Critical Review' );
    $grpid['exclude_groups'] = '6';
    }
    return $grpid;
    }
    add_filter( 'bp_after_has_profile_parse_args', 'hide_profile_group' );
    

    A few comments:

    Most of the essential code is based on this threat. I am not really a coder myself, but usually I understand what the functions are doing.

    For now I commented `// if ( bp_is_my_profile() ) :
    // echo “Edit under Profile”;
    // endif;` out, because if I leave it in, for some reason then also logged-in users only see the personal profile group instead of the Critical Review one?!

    Also, I’m not entirely sure about the use of the last function and its use / relevance, because it doesn’t seem to affect anything. This might however have to do with the fact that in order to avoid duplication of the Critical Review profile group under the actual profile tab, I’ve hidden the profile group via CSS.

    Finally, I’m running the latest WP and BP installs and you can have a look at the described behavior here. Interestingly, as you can see in this instance, the profile fields are actually adjusted to my CSS for the Critical Review profiles group – but the actual content doesn’t show correctly.

    Now, if any of you could help me out, I would highly appreciate it!

    Thank you so much in advance! 🙂

    #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
    Moderator

    @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
    Moderator

    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');
    #258439
    jaumearagay
    Participant

    Hi there! 🙂

    I want to suppress the whole Activity tab and Make the Profile the default tab. I’ve found code to do that but then I get a 404 error page when I click on a user’s link.

    This is the code I’ve found:

    /* *** */

    /* Remove Activity tab from profile */

    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’);

    /* *** */

    Is there something wrong or missing?

    Thanks in advance.

    Jaume.

    #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.

Viewing 25 results - 26 through 50 (of 154 total)
Skip to toolbar