Skip to:

Re: Private Profiles



This is a little risky for a non-programmer, but here is some code that would replace the profile-loop.php file in the skeleton member theme. Note that this theme is deprecated in the new parent-child theme setup. It is also not a sophisticated privacy component like the one Jeff is working on. It simply omits everything except the base profile fieldset when a non-member views the profile.

This is from my own installation, but I have removed some pieces (mostly formatting) to simplify things a bit. I haven’t tested it in the simplified form.

It assumes that “Base” is the base profile group name you specified in the BP dashboard settings.

* /profile/profile-loop.php
* This file loops through the profile field groups, and then each profile field to
* display the profile information that a user has entered.
* Loaded by: 'profile/index.php' (via the xprofile_get_profile() template tag)
<?php if ( bp_has_profile() ) : ?>

<?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>

<?php if ( (bp_get_the_profile_group_name() == "Base") || ( is_user_logged_in() ) ) : ?>
<div class="info-group">

<?php if ( bp_group_has_fields() ) : ?>

<h4><?php bp_the_profile_group_name() ?></h4>

<table class="profile-fields">
<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>

<?php if ( bp_field_has_data() ) : ?>

<tr<?php bp_field_css_class() ?>>
<td class="label">
<?php bp_the_profile_field_name() ?>
<td class="data">
<?php bp_the_profile_field_value() ?>

<?php endif; ?>

<?php endwhile; ?>

<?php else : ?>

<h4><?php bp_the_profile_group_name() ?></h4>

No info yet.

<?php endif; ?>


<?php endif; ?>

<?php endwhile; ?>

<?php if ( !is_user_logged_in() ) : ?>
<p class="not-a-member">You need to log in to see full member profiles.</p>
<?php endif; ?>

<?php else: ?>

<div id="message" class="info">
<p><?php _e( 'Sorry, this person does not have a public profile.', 'buddypress' ) ?></p>

<?php endif;?>

Skip to toolbar