Close Sidebar
Type & Hit Enter To Search
Recent Posts
BuddyPress

Recently for a BuddyPress project, I’ve been looking into the various ways to hide profile groups from a members public profile. There seems to be a few solutions out there. I could set the groups class to display: none in the CSS. That would certainly work in some cases, but in my case the users data would still be viewable in the source code, so it’s hardly the most secure solution.

Another solution would be to use a third party plugin, which would be nice, but I couldn’t find any that were still supported. So finally I came to the conclusion that the best solution for me (at the time of writing) was to edit the profile loop in the child theme directly.

Providing your using a child theme, you’ll find your profile loop in /wp-content/themes/your-theme-folder-name/members/single/profile/profile-loop.php. All you need to do add in a simple if statement that skips the profile group ids that you don’t want to display.

Here is my modified loop:

<!--?<span class="hiddenSpellError" pre=""-->php while ( bp_profile_groups() ) : bp_the_profile_group();
//dont show profile group 5 as it's private
if(bp_get_the_profile_group_id() != 5) :
?>
<!--?<span class="hiddenSpellError" pre=""-->php if ( bp_profile_group_has_fields() ) : ?>
<!--?<span class="hiddenSpellError" pre=""-->php do_action( 'bp_before_profile_field_content' ); ?></pre>
<div class="bp-widget <?<span class=">php bp_the_profile_group_slug(); ?>"></div>
<pre>
</pre>
<h4><!--?<span class="hiddenSpellError" pre=""-->php bp_the_profile_group_name(); ?></h4>
<pre>
<table class="profile-fields">
<!--?<span class="hiddenSpellError" pre=""-->php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
<!--?<span class="hiddenSpellError" pre=""-->php if ( bp_field_has_data() ) : ?>
<tr<?<span class="hiddenSpellError">php bp_field_css_class(); ?>>
<!--?<span class="hiddenSpellError" pre=""-->php bp_the_profile_field_name(); ?>
<!--?<span class="hiddenSpellError" pre=""-->php bp_the_profile_field_value(); ?>
</tr>
<!--?<span class="hiddenSpellError" pre=""-->php endif; ?>
<!--?<span class="hiddenSpellError" pre=""-->php do_action( 'bp_profile_field_item' ); ?>
<!--?<span class="hiddenSpellError" pre=""-->php endwhile; ?>
</table>
</div>
<!--?<span class="hiddenSpellError" pre=""-->php do_action( 'bp_after_profile_field_content' ); ?>
<!--?<span class="hiddenSpellError" pre=""-->php endif; ?>
<!--?php <span class="hiddenSpellError" pre="php "-->endif; ?>
<!--?php <span class="hiddenSpellError" pre="php "-->endwhile; ?>


The good news is that in BuddyPress 1.6, it looks like a profile privacy feature might be included. Fingers crossed! :)

About Me

Hi, as you’ve guessed I’m Ross, a freelance web developer based in Glasgow, Scotland.

The large majority of my freelance work usually involves WordPress, but I also have experience in iPhone & iPad apps and bespoke solutions.

For more information and an informal chat, please get in touch.

Get in touch

Thanks, I'll be in touch soon.

Recent Tweets

© Ross Gledhill 2014 | Powered by WordPress | Hosted by Media Temple