Skip to:
Content

BuddyPress.org

Ticket #4365: 4365.filters.patch

File 4365.filters.patch, 3.9 KB (added by imath, 8 years ago)
  • src/bp-members/bp-members-template.php

    diff --git src/bp-members/bp-members-template.php src/bp-members/bp-members-template.php
    index e565b35..8d78ea2 100644
    function bp_member_profile_data( $args = '' ) { 
    900900
    901901                // Declare local variables
    902902                $data = false;
     903                $type = false;
    903904
    904905                // Guess at default $user_id
    905906                $default_user_id = 0;
    function bp_member_profile_data( $args = '' ) { 
    934935
    935936                // Get the data for the specific field requested
    936937                if ( ! empty( $profile_data ) && ! empty( $profile_data[ $r['field'] ]['field_type'] ) && ! empty( $profile_data[ $r['field'] ]['field_data'] ) ) {
    937                         $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] );
     938                        $data = bp_unserialize_profile_field( $profile_data[ $r['field'] ]['field_data'] );
     939                        $type = $profile_data[ $r['field'] ]['field_type'];
    938940                }
    939941
    940                 return apply_filters( 'bp_get_member_profile_data', $data );
     942                return apply_filters( 'bp_get_member_profile_data', $data, $type );
    941943        }
    942944
    943945/**
  • src/bp-xprofile/bp-xprofile-filters.php

    diff --git src/bp-xprofile/bp-xprofile-filters.php src/bp-xprofile/bp-xprofile-filters.php
    index 50f10e0..f028921 100644
    add_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_format_ 
    3030add_filter( 'bp_get_the_profile_field_value',           'xprofile_filter_format_field_value_by_type', 8, 2 );
    3131add_filter( 'bp_get_the_profile_field_value',           'xprofile_filter_link_profile_data',          9, 2 );
    3232
     33add_filter( 'xprofile_get_random_profile_data_value',   'xprofile_filter_format_field_value',         1, 2 );
     34add_filter( 'xprofile_get_random_profile_data_value',   'xprofile_filter_format_field_value_by_type', 8, 2 );
     35
     36add_filter( 'bp_get_member_profile_data',               'xprofile_filter_format_field_value',         1, 2 );
     37add_filter( 'bp_get_member_profile_data',               'xprofile_filter_format_field_value_by_type', 8, 2 );
     38
    3339add_filter( 'bp_get_the_profile_field_edit_value',      'force_balance_tags' );
    3440add_filter( 'bp_get_the_profile_field_edit_value',      'esc_html'           );
    3541
  • src/bp-xprofile/bp-xprofile-functions.php

    diff --git src/bp-xprofile/bp-xprofile-functions.php src/bp-xprofile/bp-xprofile-functions.php
    index a437392..8bfb884 100644
    function xprofile_get_field_id_from_name( $field_name ) { 
    466466 * @global BuddyPress $bp The one true BuddyPress instance
    467467 * @global $wpdb WordPress DB access object.
    468468 * @global $current_user WordPress global variable containing current logged in user information
    469  * @uses xprofile_format_profile_field() Formats profile field data so it is suitable for display.
     469 * @uses bp_unserialize_profile_field()
    470470 * @return string|bool The fetched random data for the user, or false if no data or no match.
    471471 */
    472472function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) {
    function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) 
    475475        if ( empty( $field_data ) )
    476476                return false;
    477477
    478         $field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value );
     478        $field_data[0]->value = apply_filters( 'xprofile_get_random_profile_data_value', bp_unserialize_profile_field( $field_data[0]->value ), $field_data[0]->type );
    479479
    480480        if ( empty( $field_data[0]->value ) )
    481481                return false;
    function xprofile_get_random_profile_data( $user_id, $exclude_fullname = true ) 
    484484}
    485485
    486486/**
    487  * Formats a profile field according to its type. [ TODO: Should really be moved to filters ]
     487 * Formats a profile field according to its type.
     488 *
     489 * @todo Mark as deprecated?  Method is no longer used internally.
    488490 *
    489491 * @package BuddyPress Core
    490492 * @param string $field_type The type of field: datebox, selectbox, textbox etc