Skip to:
Content

BuddyPress.org

Changeset 3514


Ignore:
Timestamp:
12/05/2010 04:39:52 PM (14 years ago)
Author:
boonebgorges
Message:

maybe_unserialize profile field data in xprofile_get_field_data() before filtering and returning. Fixes #2172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile.php

    r3436 r3514  
    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 ) {
     
    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
Note: See TracChangeset for help on using the changeset viewer.