BuddyDev

Hiding BuddyPress Profile Field Groups Conditionally

Assume that you are running a BuddyPress site and you have multiple profile field groups. Now, if you don't want some of the field groups to be visible to certain users, you can do that by filtering on 'bp_after_has_profile_parse_args' and passing the field groups as the 'exclude_groups' parameter.

Here is an example where only the site admin and the user whose profile is viewed is able to see all field groups. Others will not be able to see the field group 2,3(you can change it with anything else)

You can improve it adapt to your own use cases. Hope that helps.

2 Responses to Hiding BuddyPress Profile Field Groups Conditionally

  • You are the answer to my prayers. Seriously. I have been struggling to get my head around BuddyPress and WordPress dev and these code examples are gold. You have literally made my day. For example, this conditional hiding of fields code, while not 100% what I am trying to do, could well be what gets me unstuck and developing again.

    • Thank you Matthew.
      I am glad, I could help in some way.

      All the best with your project 🙂