Hello,
i cant get profile/member links working on main activity page /activity. On profile pages etc member links are working just fine. Created new sidebar with call:
bp_get_displayed_user_nav();
/**
* Fires after the display of member options navigation.
*
* @since 1.2.4
*/
do_action( 'bp_member_options_nav' );
It displays menu items, label links but if you are on acitivity stream page links are wrong. Is there a way to fix that? I can create wp_menu there but then i will loose small annotations with numbers inside (friends number etc).
Also how to detect if i am on main activity stream page. I know there is
bp_is_current_component('activity')
but it detects both main streams and member activity stream.
Thank you.
OK, well it appears that there is actually no BP template that can be overridden for this situation. I ended up doing it by filtering the code that creates the Friends Tab in the profile. Here’s what I ended up with. If anybody sees anything wrong here, let me know. All this does is create the same tab (a list item) that BP does, except I don’t include the count.
function filter_bp_friends_tab( $args ) {
$new_args = '<li id="friends-personal-li" >'
. '<a id="user-friends" '
. 'href="' . bp_get_displayed_user_link() . 'friends/">'
. 'Friends</a></li>';
return( $new_args );
}
add_filter('bp_get_displayed_user_nav_friends', 'filter_bp_friends_tab');
note that the functions like bp_get_displayed_user_link()
are defined in the buddypress filebp-members/bp-members-template.php
Did you try just removing the calls to the nav from the template ?
Since you mention ‘Member primary navigation’, I’ll assume you are working the bp-legacy templates.
Open buddypress\bp-templates\bp-legacy\buddypress\members\single\home.php
Remove: bp_get_displayed_user_nav();
And perhaps: do_action( 'bp_member_options_nav' );
Needs more debugging, please try just after or before <?php bp_get_displayed_user_nav(); ?>
Thanks
Hi guys I have deleted the <?php bp_get_displayed_user_nav(); ?>
and would like to one by one echo out the user links on the profile page how I see fit but using the code
<li class="profile-link"><a href="<?php echo bp_core_get_user_domain( $bp->displayed_user->id ); ?>/friends"><?php _e("Activity")?></a></li>
Whiich I thought should work but doesnt as it just produces htttp://example.com/friends without the users name.
Anyone suggestions would be great! Thank you!
Hi guys does anyone know a good way to edit the bp_get_displayed_user_nav on the profile pages.
For my site design there are just too many links in the menu and I would like some of those links to be drop down options
for example
Activity >
Notifications
Messages
Profile >
Friends
Settings
Media > (from RT media plugin)
Also how would I go about adding icons to the links as well?
Anyway would be awesome if some one could help me out or point me in the right direction.
Thank you!
The easiest way to do this is to edit the home.php file. You’ll need to comment out bp_get_displayed_user_nav()
and the related markup.
Ref: your-child-theme/buddypress/members/single/home.php
Hello guys.
I’m trying to hijack this menu and place it inside my header.php file.
This menu gets echoed via the bp_get_displayed_user_nav() function that is only visible on user profile related pages so I need some sort of conditional PHP tag to prevent it from showing up in my header section when I’m not viewing one of those profile related pages of course. For some reason I can’t figure it out anymore. It’s been a while since I’ve used BuddyPress.
Not visible here
[domain]/members/
Yes show me here
[domain]/members/warrick-brown/
[domain]/members/warrick-brown/profile/
[domain]/members/warrick-brown/groups/
[domain]/members/warrick-brown/anything-else/
I tried; if bp_is_members_component() > true > echo the menu but that doesn’t seem to work. I probably need to go deeper into the single profile section or something.
?
Hi @nabilyazghi,
You could perhaps use something like this:
function blabla() {
if ( ! bp_is_my_profile() )
$nav_array = 'what_you_need';
return $nav_array;
}
add_filter('bp_get_displayed_user_nav', 'blabla', 10, 1 );
Function ref: http://hookr.io/plugins/buddypress/2.4.3/functions/bp_get_displayed_user_nav/
Hi,
I am writing some code related with buddypress profile page,and I want to display the user_nav_in in a separate page,the function bp_get_displayed_user_nav gives an error Invalid argument supplied for foreach() because the array $bp->members->nav->get_primary() does not have any values ,because the display_user->id is empty,
I tried to set up it with $bp->displayed_user->id=”ExampleId” but with no success,
Does any one have an idea?
Thank you,
Sincerely.
Nabil
Hello,
I am trying to get the header action buttons inside the profile navigation area, which currently renders as li items inside of a ul
<-- UL HERE -->
<?php bp_get_displayed_user_nav(); ?>
<?php
/**
* Fires after the display of member options navigation.
*
* @since 1.2.4
*/
do_action( 'bp_member_options_nav' );
do_action( 'bp_member_header_actions' ); ?>
<-- END UL HERE -->
as you can see, but the problem is that the bp_member_header_actions output as div containers, i need to change these to li’s, but not sure how to do it, i have tried looking in the bp_friends_template which is where the content is outputted, though it has wrapper_id and wrapper_class it does not have a definiting of wrapper or wrapper_type or container.
Any advice?
For standard BP profile tabs, try:
function zhubr_remove_profile_nav_item( $nav ) {
if ( ! bp_is_my_profile() )
$nav = '';
return $nav;
}
add_filter('bp_get_displayed_user_nav_notifications', 'zhubr_remove_profile_nav_item', 20, 1 );
add_filter('bp_get_displayed_user_nav_groups', 'zhubr_remove_profile_nav_item', 20, 1 );
// add additional calls for other tabs
To remove custom tabs, try:
function zhubr_remove_custom_profile_tab() {
if ( bp_is_user() && ! bp_is_my_profile() )
bp_core_remove_nav_item( 'events' );
}
add_action( 'bp_ready', 'zhubr_remove_custom_profile_tab', 25 );
Untested, but try:
function jake_nav_remove($nav_array) {
if( ! bp_is_my_profile() ) {
$roles = wp_get_current_user()->roles;
if (in_array('Supporter', $roles))
$nav_array = '';
}
return $nav_array;
}
add_filter('bp_get_displayed_user_nav_activity', 'jake_nav_remove', 10, 1 );
add_filter('bp_get_displayed_user_nav_profile', 'jake_nav_remove', 10, 1 );
However – removing these tabs can create problems – ‘profile’ is the default tab ( and therefore screen ) for member pages. You’ll need to decide on which tab should be default, since you may remove profile and activity.
See here:
Filters & Constants Reference
About bp_get_displayed_user_nav_
As you see, there is a a final undescore
This is a dynamic function name which need to be completed, depending the place you want it to be modified.
bp_get_displayed_user_nav_<css_id>
.
bp_get_displayed_user_nav_<css_id>
See a working example here, to understand how to use it
https://buddypress.org/support/topic/how-to-remove-sub-nav-only-for-displayed-user/#post-234852
@quinngoldwin
it goes to my personal activity instead.
It’s intended so ! You’re on a profile page, and any links added directly to buddybar or his subnav is alwways, and only, user related. It’s a contextual menu.
But you can use bp_member_options_nav
action hook which is on the template.
bp-templates/bp-legacy/buddypress/members/single/home.php
Add this snippet to bp-custom.php your your child theme functions.php:
function goldwin_custom_setup_nav() {
if ( bp_is_active( 'xprofile' ) )
?>
<li><a href="<?php bp_activity_directory_permalink(); ?>"><?php printf ('All Activities'); ?></a></li>
<?php
}
add_action( 'bp_member_options_nav', 'goldwin_custom_setup_nav' );
By default, the hook is placed as latest item of the navbar items. To get as first item, simply move the action at the begin of the list.
Default code looks like this:
<ul>
<?php bp_get_displayed_user_nav(); ?>
<?php do_action( 'bp_member_options_nav' ); ?>
</ul>
that you can chage to:
<ul>
<?php do_action( 'bp_member_options_nav' ); ?>
<?php bp_get_displayed_user_nav(); ?>
</ul>
But you can’t get your custom item as second, or third, or whatever. Only first or latest.
How to use bp-custom, functions.php and child_theme is explained on the codex.
‘Activity’ is the default tab.
If you want to remove it, you need to change the default tab.
Change Default Members Profile Landing Tab
define('BP_DEFAULT_COMPONENT', 'profile' );
function klosurdo_remove_member_nav($nav_array) {
if( !is_user_logged_in() )
$nav_array = '';
return $nav_array;
}
add_filter('bp_get_displayed_user_nav_activity', 'klosurdo_remove_member_nav', 15, 1 );
What plugin are you using to enable ‘followers’ ?
What version of BP are you using?
You could try this:
function addy_remove_profile_nav($nav_array) {
if( is_super_admin() )
return $nav_array;
if ( ! bp_is_my_profile() )
$nav_array = '';
return $nav_array;
}
add_filter('bp_get_displayed_user_nav_followers', 'addy_remove_profile_nav', 10, 1 );
Hi,
Actually no, thats not it, there is no option for that in buddypress, I need to hide the buttons notifications and settings (that are along with profile, messages groupes etc.)
it’s in the front office.
thanks a lot
PS : someone posted this, I think it’s on the right track but it doesn’t work :/
[ edited – please use ‘code’ button when posting code ]
Try this in bp-custom.php
function fanmusic_remove_profile_nav_remove( $nav ) {
$nav = '';
return $nav;
}
add_filter('bp_get_displayed_user_nav_notifications', 'fanmusic_remove_profile_nav_remove', 10, 1 );
add_filter('bp_get_displayed_user_nav_settings', 'fanmusic_remove_profile_nav_remove', 10, 1 );
<?php
/**
* BuddyPress – Users Home
*
* @package BuddyPress
* @subpackage bp-default
*/
//get theme options
global $oswc_bp;
//set theme options
$oswc_bp_sidebar_unique = $oswc_bp[‘bp_sidebar_unique’];
$oswc_bp_members_sidebar_unique = $oswc_bp[‘bp_members_sidebar_unique’];
//setup variables
$sidebar=”Default Sidebar”;
if($oswc_bp_sidebar_unique) { $sidebar=”BuddyPress Default Sidebar”; }
if($oswc_bp_members_sidebar_unique) { $sidebar=”BuddyPress Members Sidebar”; }
get_header( ‘buddypress’ ); ?>
<div class=”main-content-left”>
<div class=”page-content” id=”content”>
<?php do_action( ‘bp_before_member_home_content’ ); ?>
<div id=”item-header” role=”complementary”>
<?php locate_template( array( ‘members/single/member-header.php’ ), true ); ?>
</div><!– #item-header –>
<div id=”item-nav”>
<div class=”item-list-tabs no-ajax” id=”object-nav” role=”navigation”>
<?php bp_get_displayed_user_nav(); ?>
<?php do_action( ‘bp_member_options_nav’ ); ?>
</div>
</div><!– #item-nav –>
<div id=”item-body”>
<?php do_action( ‘bp_before_member_body’ );
if ( bp_is_user_activity() || !bp_current_component() ) :
locate_template( array( ‘members/single/activity.php’ ), true );
elseif ( bp_is_user_blogs() ) :
locate_template( array( ‘members/single/blogs.php’ ), true );
elseif ( bp_is_user_friends() ) :
locate_template( array( ‘members/single/friends.php’ ), true );
elseif ( bp_is_user_groups() ) :
locate_template( array( ‘members/single/groups.php’ ), true );
elseif ( bp_is_user_messages() ) :
locate_template( array( ‘members/single/messages.php’ ), true );
elseif ( bp_is_user_profile() ) :
locate_template( array( ‘members/single/profile.php’ ), true );
elseif ( bp_is_user_forums() ) :
locate_template( array( ‘members/single/forums.php’ ), true );
elseif ( bp_is_user_settings() ) :
locate_template( array( ‘members/single/settings.php’ ), true );
elseif ( bp_is_user_notifications() ) :
locate_template( array( ‘members/single/notifications.php’ ), true );
// If nothing sticks, load a generic template
else :
locate_template( array( ‘members/single/plugins.php’ ), true );
endif;
do_action( ‘bp_after_member_body’ ); ?>
</div><!– #item-body –>
<?php do_action( ‘bp_after_member_home_content’ ); ?>
</div>
</div>
<div class=”sidebar”>
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar($sidebar) ) : else : ?>
<div class=”widget-wrapper”>
<div class=”widget”>
<div class=”section-wrapper”><div class=”section”>
<?php _e(‘ Made Magazine ‘, ‘made’ ); ?>
</div></div>
<div class=”textwidget”>
<p><?php _e( ‘This is a widget panel. To remove this text, login to your WordPress admin panel and go to Appearance >> Widgets, and drag & drop a widget into the corresponding widget panel.’, ‘made’ ); ?></p>
</div>
</div>
thats what I did:
</div>
<?php endif; ?>
</div>
<br class=”clearer” />
<?php get_footer( ‘buddypress’ ); ?>
You’re looking at the templates that render the content for tabs.
But you want to remove tabs.
Because ‘groups’ may be the only tab available, you need to make ‘groups’ the default component.
You may need to add or remove one or more add_filter
calls depending on your installation.
Try this in your bp-custom.php file:
define( 'BP_DEFAULT_COMPONENT', 'groups' );
function izzy_adjust_profile_nav() {
if ( ! is_user_logged_in() ) {
add_filter('bp_get_displayed_user_nav_activity', 'izzy_profile_nav_remove', 10, 1 );
add_filter('bp_get_displayed_user_nav_friends', 'izzy_profile_nav_remove', 10, 1 );
add_filter('bp_get_displayed_user_nav_forums', 'izzy_profile_nav_remove', 10, 1 );
add_filter('bp_get_displayed_user_nav_xprofile', 'izzy_profile_nav_remove', 10, 1 );
}
}
add_action( 'bp_init', 'izzy_adjust_profile_nav' );
function izzy_profile_nav_remove($nav_array) {
$nav_array = '';
return $nav_array;
}
I’ve had to another route, I’m trying to add a logged in users nav into all pages, I can do this by adding this code to my page template:
<div class=”left-nav”>
<?php bp_get_displayed_user_nav(); ?>
<?php do_action( ‘bp_get_options_nav’ ); ?>
</div>
But all the links then rendered are relative it doesn’t work, is there a way of making this work globally?
Links are added either by a plugin or by hooking into that menu.
https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/how-to-remove-and-add-items-in-bp_get_displayed_user_nav/ is quite a useful thread on adding to menus.
As for deleting the sidebar, that would need a link to see your theme before saying if something was going to work or not.