Skip to:
Content

BuddyPress.org

Changeset 8631


Ignore:
Timestamp:
07/16/2014 09:53:18 AM (7 years ago)
Author:
djpaul
Message:

xProfile: when updating a user profile, make sure the actions are passed the field's current (new) value.

Previously, we've been passing these actions the values that we've told xProfile to set, instead of the
field's actual (new) value. Most of the time, these will be identical, but with BP 2.0's xProfile field
type improvements, there are more lower-level places where the value could be filtered before the data's
written to the database.

In this situation, the field's actual new value could be different from what we've been returning in the
xprofile_profile_field_data_updated and xprofile_updated_profile actions.

See #5755

File:
1 edited

Legend:

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

    r8630 r8631  
    118118                    'visibility' => xprofile_get_field_visibility_level( $field_id, bp_displayed_user_id() ),
    119119                );
     120
     121                // Update the field data and visibility level
     122                xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level );
     123                $field_updated = xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[ $field_id ] );
     124                $value         = xprofile_get_field_data( $field_id, bp_displayed_user_id() );
     125
    120126                $new_values[ $field_id ] = array(
    121127                    'value'      => $value,
    122                     'visibility' => $visibility_level,
     128                    'visibility' => xprofile_get_field_visibility_level( $field_id, bp_displayed_user_id() ),
    123129                );
    124130
    125                 if ( !xprofile_set_field_data( $field_id, bp_displayed_user_id(), $value, $is_required[$field_id] ) ) {
     131                if ( ! $field_updated ) {
    126132                    $errors = true;
    127133                } else {
    128134                    do_action( 'xprofile_profile_field_data_updated', $field_id, $value );
    129135                }
    130 
    131                 // Save the visibility level
    132                 xprofile_set_field_visibility_level( $field_id, bp_displayed_user_id(), $visibility_level );
    133136            }
    134137
Note: See TracChangeset for help on using the changeset viewer.