How to remove the “profile” tab in Budypress except from user’s own profile

Adapted from this snippet by @modemlooper:

  • $bp->displayed_user->id is the way to be sure that user is checking its own profile. global $bp; needs to be invoked before.
  • bp_core_remove_nav_item() is a function still undocumented in Budypress Codex (official documentation).

View the code on Gist.