Function to remove tab in buddypress profile: need help with check

I’m trying to write a function to hide a Buddypress tab if its empty.

For example, I have this code I found online for the activity tab:

function hide_non_friend_profile_activity_tab(){

if(bp_is_my_profile()|| is_super_admin())

return ;




However, I would like to have it more generic so that if the tab is empty (ie no data, it says “Sorry, there were no sites found.”:wink: then the whole tab it removed of hidden. If there is anything in it it will show up.

The problem is that the tab is not the activity one (so the friends issue above is not an issue for me) and of course I need some sort of check.

The actual tab is this one – the channels slug or TV Channel tab: