Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to hide visibility options for empty values

@shanebp

Moderator

Nice hat.

Yes, the use ofbp_field_has_data() can be a bit confusing.
Remember that in this context, rather than check the field value, it checks if there is data in the visibility setting for that field – which will always be true.
And bp_the_profile_field_value will be NULL for the same reason.

Try this:

<?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
	<?php 
	$this_field = xprofile_get_field_data( bp_get_the_profile_field_id(), bp_displayed_user_id(), 'comma' ); 
	if( !empty( $this_field ) ) :
	?>
	   <tr <?php bp_field_css_class(); ?>>
		<td class="field-name"><?php bp_the_profile_field_name(); ?></td>
		<td class="field-visibility"><?php bp_profile_settings_visibility_select(); ?></td>
	   </tr>
	<?php endif; ?>
<?php endwhile; ?>
Skip to toolbar