Ticket #7049: 7049.02.diff
File 7049.02.diff, 3.6 KB (added by , 8 years ago) |
---|
-
src/bp-xprofile/classes/class-bp-xprofile-user-admin.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-user-admin.php src/bp-xprofile/classes/class-bp-xprofile-user-admin.php index 47c19eb..6a78392 100644
class BP_XProfile_User_Admin { 250 250 $errors = false; 251 251 252 252 // Now we've checked for required fields, let's save the values. 253 $old_values = $new_values = array(); 253 254 foreach ( (array) $posted_field_ids as $field_id ) { 254 255 255 // Certain types of fields (checkboxes, multiselects) may come 256 // through empty. Save them as an empty array so that they don't 257 // get overwritten by the default on the next edit. 256 /* 257 * Certain types of fields (checkboxes, multiselects) may come 258 * through empty. Save them as an empty array so that they don't 259 * get overwritten by the default on the next edit. 260 */ 258 261 $value = isset( $_POST['field_' . $field_id] ) ? $_POST['field_' . $field_id] : ''; 259 262 260 if ( ! xprofile_set_field_data( $field_id, $user_id, $value, $is_required[ $field_id ] ) ) { 263 $visibility_level = ! empty( $_POST['field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public'; 264 /* 265 * Save the old and new values. They will be 266 * passed to the filter and used to determine 267 * whether an activity item should be posted. 268 */ 269 $old_values[ $field_id ] = array( 270 'value' => xprofile_get_field_data( $field_id, $user_id ), 271 'visibility' => xprofile_get_field_visibility_level( $field_id, $user_id ), 272 ); 273 274 // Update the field data and visibility level. 275 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level ); 276 $field_updated = xprofile_set_field_data( $field_id, $user_id, $value, $is_required[ $field_id ] ); 277 $value = xprofile_get_field_data( $field_id, $user_id ); 278 279 $new_values[ $field_id ] = array( 280 'value' => $value, 281 'visibility' => xprofile_get_field_visibility_level( $field_id, $user_id ), 282 ); 283 284 if ( ! $field_updated ) { 261 285 $errors = true; 262 286 } else { 263 287 … … class BP_XProfile_User_Admin { 271 295 */ 272 296 do_action( 'xprofile_profile_field_data_updated', $field_id, $value ); 273 297 } 274 275 // Save the visibility level.276 $visibility_level = ! empty( $_POST['field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public';277 xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );278 298 } 279 299 280 300 /** 281 * Fires after all of the profile fields have been saved.301 * Fires after all XProfile fields have been saved for the current profile. 282 302 * 283 303 * @since 1.0.0 304 * @since 2.6.0 Added $old_values and $new_values parameters. 284 305 * 285 * @param int $user_id ID of the user whose data is being saved. 286 * @param array $posted_field_ids IDs of the fields that were submitted. 287 * @param bool $errors Whether or not errors occurred during saving. 306 * @param int $user_id ID for the user whose profile is being saved. 307 * @param array $posted_field_ids Array of field IDs that were edited. 308 * @param bool $errors Whether or not any errors occurred. 309 * @param array $old_values Array of original values before update. 310 * @param array $new_values Array of newly saved values after update. 288 311 */ 289 do_action( 'xprofile_updated_profile', $user_id, $posted_field_ids, $errors );312 do_action( 'xprofile_updated_profile', $user_id, $posted_field_ids, $errors, $old_values, $new_values ); 290 313 291 314 // Set the feedback messages. 292 315 if ( ! empty( $errors ) ) {