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 🙂

Leave a Reply

Are you looking for support?

Please ask support questions in BuddyDev Forum and help us serve you better. Please use comment for general discussion/feature suggestions.

Your email address will not be published. All the fields marked as * are required.

If you are posting code, please use <pre> { Your Code Block } </pre>. Example:- <pre> echo $name; </pre>

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">