Skip to:
Content

BuddyPress.org

Ticket #2172: 2172-1.patch

File 2172-1.patch, 1.6 KB (added by boonebgorges, 15 years ago)
  • bp-xprofile.php

     
    597597 *
    598598 * Fetches profile data for a specific field for the user.
    599599 *
     600 * When the field value is serialized, this function unserializes and filters each item in the array
     601 * that results.
     602 *
    600603 * @package BuddyPress Core
    601  * @param $field The ID of the field, or the $name of the field.
    602  * @param $user_id The ID of the user
     604 * @param mixed $field The ID of the field, or the $name of the field.
     605 * @param int $user_id The ID of the user
    603606 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    604  * @uses BP_XProfile_ProfileData::get_value_byfieldname() Fetches the value based on the params passed.
    605  * @return The profile field data.
     607 * @uses BP_XProfile_ProfileData::get_value_byid() Fetches the value based on the params passed.
     608 * @return mixed The profile field data.
    606609 */
    607610function xprofile_get_field_data( $field, $user_id = null ) {
    608611        global $bp;
     
    625628        if ( !$field_id )
    626629                return false;
    627630
    628         return apply_filters( 'xprofile_get_field_data', BP_XProfile_ProfileData::get_value_byid( $field_id, $user_id ) );
     631        $values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field_id, $user_id ) );
     632
     633        if ( is_array( $values ) ) {
     634                $data = array();
     635                foreach( (array)$values as $value ) {
     636                        $data[] = apply_filters( 'xprofile_get_field_data', $value );
     637                }
     638        } else {
     639                $data = apply_filters( 'xprofile_get_field_data', $values );
     640        }
     641       
     642        return $data;
    629643}
    630644
    631645/**