Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/28/2014 06:23:15 PM (12 years ago)
Author:
djpaul
Message:

xProfile: fix profile fields not rendering if their value is "0".

This was caused by a reliance on the empty() function in a few places, which was causing us to
not handle "0" (both as int and string) as a valid field value. In turn, this was causing the
profile field template loop to skip rendering the affected field.

Fixes #5731, props DJPaul and r-a-y.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r8489 r8554  
    143143        $field = $this->next_field();
    144144
    145         $value = !empty( $field->data ) && !empty( $field->data->value ) ? maybe_unserialize( $field->data->value ) : false;
    146 
    147         if ( !empty( $value ) ) {
     145        // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731
     146        if ( ! empty( $field->data ) && ( ! empty( $field->data->value ) || '0' == $field->data->value ) ) {
     147            $value = maybe_unserialize( $field->data->value );
     148        } else {
     149            $value = false;
     150        }
     151
     152        if ( ! empty( $value ) || '0' == $value ) {
    148153            $this->field_has_data = true;
    149154        } else {
Note: See TracChangeset for help on using the changeset viewer.