@bruce7075,
here a complete solution you can use for friends privacy.
– Whe’re going to show the friends menu only to… friends !
– We remove friends activity.
Copy this to bp-custom.php
function bpfr_maybe_hide_friends_nav_etc() {
$retval = false;
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 filed
if ( ! bpfr_maybe_hide_friends_nav_etc() ) {
return;
}
// otherwise, we remove the nav
bp_core_remove_nav_item( 'friends' ); // bp topnav
bp_core_remove_subnav_item( 'activity', 'friends' ); //bp subnav (my activities, my groups, etc)
}
add_action( 'bp_ready', 'bpfr_hide_friends_nav_to_non_friends' );
// we want also to remove all friends related activities to non friends
function bpfr_hide_friends_activity_type_to_non_friends( $activity_action = array(), $component_id = '' ) {
// if condition is not filed we go back to original output
if ( 'friends' != $component_id || ! bpfr_maybe_hide_friends_nav_etc() ) {
return $activity_action;
}
// otherwise, we remove member from context
$activity_action['context'] = array_diff( $activity_action['context'], array( 'member' ) );
return $activity_action;
}
add_filter( 'bp_activity_set_action', 'bpfr_hide_friends_activity_type_to_non_friends', 10, 2 );
Related topic (other solution, or strict answer to your question) š
https://buddypress.org/support/topic/documentation-for-remove_action-activity-streams/#post-242974
function bpfr_remove_change_avatar_tab() {
global $bp;
bp_core_remove_subnav_item( 'profile', 'change-avatar' );
}
add_action( 'bp_ready', 'bpfr_remove_change_avatar_tab', 15 );
BuddyBar items
Source: bp-core-buddybar.php
function bp_core_remove_subnav_item( $parent_id, $slug )
and to remove a nav item
function bp_core_remove_nav_item( $parent_id )
I need some help. I’ve decided to remove the the messages->starred from BBP Activity and the Admin bar links.
I’ve tried a lot of functions and none of them seem to be working.
four examples:
1. $bp->bp_nav[‘starred’] = false;
2. function remove_nav_items() {
bp_core_remove_nav_item( ‘starred’ );
}
add_action( ‘bp_setup_nav’, ‘remove_nav_items’);
// ——- End Removes Forum link Activity feed ————- //
// ——- Removes member link forum AdminBar ————- //
3. $wp_admin_bar->remove_menu(‘starred’);
4. function the_bp_admin_bar_remove() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu( ‘my-account-starred’ );
}
add_action( ‘bp_setup_admin_bar’, ‘the_bp_admin_bar_remove’, 301 );
I’ve done so successfully using CSS but I would like to use the functions instead. Can you please help?
li#starred-personal-li{
display:none;
}
li#wp-admin-bar-my-account-messages-starred{
display:none;
}
Hi,
I don’t want to show the activity as the default when you go to a groups home page. I would prefer to remove the tab ‘Home’ and have ‘Profile’ as the first tab.
I did something similar for the Profile page using the code below.
define('BP_DEFAULT_COMPONENT', 'profile' );
function bpfr_hide_top_nav() {
if( bp_is_active('xprofile' ) ) {
bp_core_remove_nav_item( 'activity' );
}
}
add_action( 'bp_ready', 'bpfr_hide_top_nav' );
Below is code I have tried using for the Groups page but it does not have any effect:
function bpgroups_hide_home_nav() {
bp_core_remove_nav_item( 'home' );
}
add_action ( 'bp_group_header_actions', 'bpgroups_hide_home_nav' );
function bpgroups_forum_first_tab() {
global $bp;
$bp->bp_options_nav['groups']['home']['position'] = '150';
}
add_action('wp', 'bpgroups_forum_first_tab');
Can anyone help me achieve this?
Please do not double post.
try this:
function urbanfix_remove_nav_item() {
if( current_user_cannot("access_s2member_level2") )
bp_core_remove_nav_item('listings');
}
add_action( 'wp', 'urbanfix_remove_nav_item' );
WP+BP Versions= Latest.
urban-fix.co.uk
I would like to hide a plugin generated buddypress tab, so after looking around I found this code and modified it a little:
<?php
function bp_remove_nav_item() {
if(current_user_cannot(āaccess_s2member_level2ā³))
global $bp;
bp_core_remove_subnav_item( $bp->profile->slug, āchange-avatarā );
}
add_action( āwpā, ābp_remove_nav_itemā );
?>
This worked perfectly well so i edited the following line:
bp_core_remove_subnav_item( $bp->profile->slug, āchange-avatarā );
to
bp_core_remove_nav_item('listings');
And now the full code looks like this;
function bp_remove_nav_item() {
if(is_user_logged_in("true") )
if(current_user_cannot("access_s2member_level2"))
global $bp;
bp_core_remove_nav_item('listings');
}
add_action( 'wp', 'bp_remove_nav_item' );
However this removes the ‘listings’ tab for all, any idea what im doing wrong?
Thanks in advance,
Hi,
I want to remove the activity stream from my profile nav bar, but only to the non member public. I have tried the following unsuccessfully, however it removed all the other icons no problem.
Thanks
Ken
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( ‘following’ );
bp_core_remove_nav_item( ‘followers’ );
The Theme I am using is KLEO by Seventh Queen
Buddy Press version Version 2.2.1
Website:http://www.cmpg-annex.org/
Other Plugins
Akismet
bbPress
BuddyPress Cover Photo
K Elements
MOJO Marketplace
Paid Memberships Pro
PMPro MailChimp Integration
PMPro Register Helper
PMPro Set Expiration Dates
Register Helper Example
Revolution Slider
rtMedia Pro for WordPress, BuddyPress and bbPress
The Events Calendar
WPBakery Visual Composer
Profile default tab is member’s activity. You have to modify this first and assign another tab to default. For example, profile tab.
define('BP_DEFAULT_COMPONENT', 'profile' );
Now you can use this to remove the activity tab. Note that the second if is related to visitor, you can remove it if you never want to show the activity tab.
function bpfr_hide_top_nav() {
if( bp_is_active('xprofile' ) )
if( !is_user_logged_in() ) {
bp_core_remove_nav_item( 'activity' );
}
}
add_action( 'bp_ready', 'bpfr_hide_top_nav' );
Hi again,
I’d like to remove the Groups tab in a users profile, as I’ve now got new users automatically added upon registration (see here https://buddypress.org/support/topic/how-to-add-new-members-to-groups-automatically/ for how: and a HUGE thanks to @modemlooper and @mrjarbenne for this).
I’ve found previous threads and which have given this:
// removing groups tab from profile
define( āBP_DEFAULT_COMPONENTā, āprofileā );
function bp_remove_nav_tabs() {
global $bp;
bp_core_remove_nav_item( āgroupsā );
}
add_action( ābp_setup_navā, ābp_remove_nav_tabsā, 15 );
which I’ve added into my bp-custom.php
This works great! BUT I’m sure I’ve seen somewhere (can’t track it down now) that you can also declare it as ‘false’ to remove it, so something like this:
$bp->bp_nav['groups']['position'] = false;
Is this because of the recent BP updates? or is it just a different way? Or have I totally imagined it?!
Any insight would be great! Thanks.
Hi.. thank you to keep guiding me.
I don’t know why those code for single groups page doesn’t working in my site.
Then I tried to modify nav tab in single members page those can working good.
This what I have in bp-custom.php:
<?php
function edit_tabs_options() {
global $bp;
// MODIFY GROUP TABS
$bp->bp_options_nav['groups']['home']['name'] = 'Group Activity'; //NOT WORK
$bp->bp_nav['groups']['home']['name'] = 'Member Activity 2'; //NOT WORK
//MODIFY MEMBERS TABS
$bp->bp_nav['home']['name'] = 'Member Activity'; //IT'S WORK
bp_core_remove_nav_item( 'forums' ); //IT'S WORK
bp_core_remove_subnav_item( 'profile', 'change-avatar' ); //IT'S WORK
}
add_action( 'bp_setup_nav', 'edit_tabs_options' );
?>
Last try on fresh install wp + bp with default theme. I will let you know if those code works or not.
Add this to your child-theme functions.php or to bp-custom.php
Not sure it will work with your theme, and ‘activity’ tab seems now impossible to remove (since 2.2 at least). I don’t know why exactly. Uncomment both lines to see if it works for you.
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( 'profile' );
bp_core_remove_nav_item( 'friends' );
bp_core_remove_nav_item( 'groups' );
bp_core_remove_nav_item( 'forums' );
//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' );
}
}
add_action( 'bp_ready', 'bpfr_hide_top_nav', 10 );
You could be right. I think bp_core_remove_nav_item() might do a little more than just visually removing an item from the member’s nav menu.
If it helps, this is the method that adds the item to the nav menu.
No luck with
if ( bp_is_user() && bp_is_current_component( 'achievements' ) && bp_is_current_action( 'all' ) )
return;
My guess is that since I removed the tab with bp_core_remove_nav_item('achievements'); that it is treating it like Buddypress is disabled like you mentioned above.
Thanks for the reply Henry.
I experimented with the code but couldn’t get it to work. I believe it has something to do with if ( bp_current_action() != 'achievements' )
I’m not sure if this is the best way to describe it, but when I previously used bp_core_remove_nav_item('achievements'); it made the /members/username/achievements outside of the buddpress page. It basically created a new page that had nothing but a list of the user’s achievements. The part it called from the plugin code. It doesn’t show the username, avatar or anything else from buddypress.
Also thanks for that update Shane.
Hello, I have Buddypress and Achievements for WordPress (the author is not active or providing support). This is an internal company site and I want to make the Achievements private so that users can only see their own achievements.
I’ve figured out how to make the xprofile Achievements tab only appear for the current user and admins with this code:
function hide_achievements_from_users() {
global $bp;
if ((bp_loggedin_user_id() == bp_displayed_user_id()) || (current_user_can('manage_options'))){
return;
}
bp_core_remove_nav_item('achievements');
}
add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );
However a user can still browse other user’s achievements by manually typing out the url like http://mysite.com/members/username/achievements/
Is there a way I can make this section of user’s profiles private so that only they (and admins) can view it? Users should still be able to visit another user’s profile, it is only the /achievements/ at the end of the URL which needs to be blocked.
Thanks for the reply. I made some changes to the code before reading and was able to accomplish removing the tab from buddypress profiles with this:
function hide_achievements_from_users() {
global $bp;
if ((bp_loggedin_user_id() == bp_displayed_user_id()) || (current_user_can('administrator'))){
return;
}
bp_core_remove_nav_item('achievements');
}
add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );
However I’m stuck on how to 404 the pages if they manually type out the URL
In your code I see:
// I guess we should 404 this page because this member isn't an admin or the displayed member.
$wp_query->set_404();
status_header( 404 );
nocache_headers();
How do I get this to apply only when it is http://mysite.com/members/<username>/achievements?
Hello, I have the “Achievements for WordPress” Plugin, it basically creates an “Achievements” tab in every user’s profile and displays their Achievements.
I would like to hide this so that only the user and admins can see their own achievements.
I tried adding this code:
function hide_achievements_from_users() {
$role = xprofile_get_field_data( 'Membership' );
if( $role !='Administrator' )
bp_core_remove_nav_item('achievements');
}
add_action( 'bp_setup_nav', 'hide_achievements_from_users', 99 );
However this obviously hides it from everyone but admins, and I can still see the achievements by going to /members/<username>/achievements, I need this to be completely hidden so the user would get a 404 error or redirect if they tried to type out the URL.
Thanks
I found the problem!!
For future users who might experience something like this:
I had modified the default members navigation options using bp_core_remove_nav_item(). One of the nav items I removed was messaging. I suppose removing the nav item somehow breaks the whole function. I had encountered a similar problem when I removed the ‘profile’ tab – it broke everything! Does anyone have any comments on ways to remove the nav options without breaking things? As of now, I’m using CSS display:none to hide the profile and messaging tabs.
@henrywright
Thank you for your reply, though I am not quite understanding.
You linked forum mentions to insert the “define” commands into the wp-config.php file. It does ot mention where exactly to insert the settings. I played around with it though nothing happened.
bp_core_remove_nav_item() would go where? Do I add it as a general function?
Hi @eversatile
I have been trying to find the file location of the profile and group navigation menus, with no luck
There isn’t a template file which you can change if that’s what you mean, but…
I would like to change āforumsā to ādiscussā and remove the āmembersā from groups menu, etc
You can customise slugs quite easily. See the Customizable Slugs in BuddyPress article.
bp_core_remove_nav_item() will let you remove nav items from the navigation. There is also bp_core_remove_subnav_item() for removing sub nav items.
You can use bp_core_remove_nav_item( $parent_id ) to remove items from the navigation array. $parent_id is the slug of the parent navigation item. So, for example:
function my_nav_item_removal_function() {
bp_core_remove_nav_item( 'friends' );
}
add_action( 'init', 'my_nav_item_removal_function' );
hi @kostas-gogas,
try this:
bp_core_remove_nav_item( ‘friends’ ); // bp topnav
bp_core_remove_subnav_item( ‘activity’, ‘friends’ ); //bp subnav (my activities, my groups, etc)
add_action( ‘bp_ready’,’your function’);
action hook bp-core-dependency.php:104
Fire the ‘bp_ready’ action, which runs after BP is set up and the page is about to render.
Hi @dmccuiston,
here is another solution which let you remove easily nav and subnav items to any visitor and users who are not friends.
If one or all items are removed, a message is displayed.
Put these 3 functions in bp-custom.php or child-theme functions.php
function bpfr_view_profile_msg() {
// msg in case the nav item is removed
if ( bpfr_maybe_hide_friends_nav_etc( $retval ) )
echo'<h3>Sorry, you can only view the profile of your friends !</h3>';
}
add_action( 'template_notices','bpfr_view_profile_msg' );
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( 'profile' );
bp_core_remove_nav_item( 'groups' );
bp_core_remove_nav_item( 'forums' );
//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' );
here’s some clues:
First you need to check the user’s role/capabilities and then remove the navigation menu for these users. For me, I used:
if (current_user_can('none_admin_role')){bp_core_remove_nav_item( 'notifications');}}
add_action( 'wp', 'bp_remove_nav_item' );
You then still need to remove it from the admin bar. My code:
function my_remove_admin_menu(){
global $wp_admin_bar;
if (current_user_can('none_admin_role'))
{
$wp_admin_bar->remove_menu('notifications');
}
}
add_action('bp_setup_admin_bar', 'my_remove_admin_menu',301);
hopefully, this does the trick for you. I took me while to figure this out…goodluck.