Seems this has something to do with function has_fields() :
function has_fields() {
$has_data = false;
for ( $i = 0; $i < count( $this->group->fields ); $i++ ) {
$field = &$this->group->fields[$i];
if ( $field->data->value != null ) {
$has_data = true;
}
}
if ( $has_data )
return true;
return false;
}
print_r($field) returns
teststdClass Object ( [id] => 1 [name] => Name [type] => textbox [group_id] => 1 ) stdClass Object ( [id] => 2 [name] => Name [type] => textbox [group_id] => 1 ) stdClass Object ( [id] => 3 [name] => First Name [type] => textbox [group_id] => 1 ) stdClass Object ( [id] => 4 [name] => Both Names [type] => textbox [group_id] => 1 )
print_r($field->data) returns FALSE…
Ok, I founded out :
if ( bp_has_profile() ) {
while ( bp_profile_groups() ) : bp_the_profile_group();
global $group;
$one_group = array();
$one_group[‘id’] = $group->id;
$one_group[‘name’] = $group->name;
$groups[ $group->id ] = $one_group;
//if ( bp_profile_group_has_fields() ) {
while ( bp_profile_fields() ) : bp_the_profile_field();
//if ( bp_field_has_data() ) {
global $field;
$one_field = array();
$one_field[‘id’] = $field->id;
$one_field[‘name’] = $field->name;
$fields[] = $one_field;
//}
endwhile;
//}
endwhile;
}
Hope that it’s ok to comment those lines…
Can you post this in a ticket please?
this hasn’t be fixed yet. Has the ticket been created?
Moreover what was bp_fields_has_data supposed to do originally? Because if it should check if the field exists, it seems straightforward to fix.
@grosbouff For the purpose of your plugin, bp_profile_group_has_fields gets in the way. The purpose of bp_profile_group_has_fields in the default theme, is that it will skip over any group of fields that have no values filled in when inside the profile loop.
I think what you want to use is bp_field_has_data().
I also don’t think that this is a bug. All of those functions are doing exactly what is expected.
Can you explain in more detail what you need these functions to do?