How to Keep Blog Tracking but Hide Blogs(0) tab for non-blogging Members
-
Most members will not have a blog in most cases. How can I can keep blog tracking but hide the blogs tab in the user nav when Blogs(0)?
-
Anyone have a clue how to show object nav tabs only if they exist for a member for example if blogs(0), links(0) tab then hide!
Try putting this in your plugins/bp-custom.php file:
function remove_blogs_nav_for_zero() {
global $bp;if ( bp_blogs_total_blogs_for_user() == 0 )
bp_core_remove_nav_item( $bp->blogs->slug );
}
add_action( 'bp_setup_nav', 'remove_blogs_nav_for_zero', 11 );
You got it!
I can confirm it works
Re: blog tracking – I may have overlooked something, but I recall that once you’re a member of BP community in main site or where BP is defined in install, you already have one blog counted in the site. And when a member creates a blog within the install, the member has now two blogs to his/her credit.
So wouldn’t it be logical to have `if ( bp_blogs_total_blogs_for_user() == 1 )` instead in the function?I don’t think that’s the case.
You only have a blog if you’re the administrator of a blog.
the main site was assigned to members a while back in an earlier version 1.1 round abouts(i remember because i had asked about it a while back because I was having issues with the limit blogs per user plugin)….it’s been “fixed” since then not to assign the main site as one of your blogs.
That’s correct, Nahum.
I’m using child them which only has a style.css, I don’t have this bp_custom.php file in either bp-default them or child them. Can I create this bp_custom.php in Child them folder? Is it ok if this file contain only the above code?
bp-custom.php never exists it’s user created, it can contain nothing at all if you wish.
And make sure that bp-custom.php goes in your wp-content/plugins directory, NOT in the theme folder.
I created an empty bp_custom.php in wp-content/plugins folder, added the above code. but nothing happened. no matter I put in == 0, or == 1, or == 2, the blogs tab is still there.
Maybe because my user profile is at root directory? ( http://mydomain.com/username/ )@imjscn – you’ve got the file name wrong, you need a hyphen not an underscore bp-custom.php
ok, I changed to bp-custom.php, this time something happens– the code shows up at my blog header area pushing the header picture down 2 lines, and the blogs tab still in profile page. ( I tried both copy/paste the code or hard typing, get the same result. Also tried to change the files Charactor Encoding from us-ascii to utf-8, neither works). Please help!!!
At the beginning of your bp-custom.php file, make sure you have
`<?php`
and at the end make sure you have
`?>`OMG, what a super dummy I am !!!
Thanks! Fully dancing after the magical marks@boonebgorges, if I want to do this on the header of profile page—
if user ID is 1 or 2, displayABCinstead of
“last update’, “mention this user”….if user is anybody else, display item-meta as normal.
How to do this?@imjscn – post that as a separate support question
I thought the same would work for groups…but it’s throwing the group count # up above the header when I use alone or in conjunction with the blogs snippet.
`function remove_groups_nav_for_zero() {
global $bp;
if ( bp_groups_total_count_for_user() == 0 )
bp_core_remove_nav_item( $bp->groups->slug );
}
add_action( ‘bp_setup_nav’, ‘remove_groups_nav_for_zero’, 11 );
`Any ideas why this is happening…and not with the blogs one.
- The topic ‘How to Keep Blog Tracking but Hide Blogs(0) tab for non-blogging Members’ is closed to new replies.