- Timestamp:
- 03/22/2021 07:45:24 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
r12781 r12869 317 317 * 318 318 * @since 2.0.0 319 * 320 * @param int $user_id ID of user whose data is being queried. 321 * @param array $field_ids Array of field IDs to query for. 319 * @since 8.0.0 Checks if a null field data is an xProfile WP Field. 320 * Adds a new parameter `$field_type_objects` to pass the list of field type objects. 321 * 322 * @param int $user_id ID of user whose data is being queried. 323 * @param array $field_ids Array of field IDs to query for. 324 * @param array $field_type_objects Array of field type objects keyed by the queried filed IDs. 322 325 * @return array 323 326 */ 324 public static function get_data_for_user( $user_id, $field_ids ) {327 public static function get_data_for_user( $user_id, $field_ids, $field_type_objects = array() ) { 325 328 global $wpdb; 326 329 … … 340 343 $d = new stdClass; 341 344 $d->id = $ud->id; 345 $d->table_name = $bp->profile->table_name_data; 342 346 $d->user_id = $ud->user_id; 343 347 $d->field_id = $ud->field_id; … … 360 364 // to avoid future cache misses. 361 365 } else { 362 $d = new stdClass; 363 $d->id = ''; 366 $d = new stdClass; 367 368 // Check WordPress if it's a WordPress field. 369 if ( isset( $field_type_objects[ $field_id ]->wp_user_key ) ) { 370 $meta = $field_type_objects[ $field_id ]->get_field_value( $user_id, $field_id ); 371 $d->id = $meta['id']; 372 $d->value = $meta['value']; 373 $d->table_name = $meta['table_name']; 374 375 } else { 376 $d->id = ''; 377 $d->value = ''; 378 } 379 380 $d->table_name = ''; 364 381 $d->user_id = $user_id; 365 382 $d->field_id = $field_id; 366 $d->value = '';367 383 $d->last_updated = ''; 368 384 … … 397 413 * 398 414 * @since 1.2.0 415 * @since 8.0.0 Checks if a null field data is an xProfile WP Field. 399 416 * 400 417 * @param int $user_id ID of the user. … … 431 448 'field_id' => $field->id, 432 449 'field_type' => $field->type, 433 'field_data' => $field->data->value,434 450 ); 451 452 if ( is_null( $field->data ) ) { 453 if ( 1 === $field->id ) { 454 $profile_data[ $field->name ]['field_data'] = $user->display_name; 455 } elseif ( isset( $field->type_obj ) && $field->type_obj instanceof BP_XProfile_Field_Type && isset( $field->type_obj->wp_user_key ) ) { 456 $meta = $field->type_obj->get_field_value( $user->ID, $field->id ); 457 458 if ( isset( $meta['value'] ) ) { 459 $profile_data[ $field->name ]['field_data'] = $meta['value']; 460 } 461 } else { 462 $profile_data[ $field->name ]['field_data'] = false; 463 } 464 } else { 465 $profile_data[ $field->name ]['field_data'] = $field->data->value; 466 } 435 467 } 436 468 } … … 476 508 * 477 509 * @since 1.0.0 510 * @since 8.0.0 Checks if a null field data is an xProfile WP Field. 478 511 * 479 512 * @param int $field_id ID of the field. … … 525 558 // avoid cache misses and PHP notices. 526 559 } else { 527 $d = new stdClass; 528 $d->id = ''; 560 $d = new stdClass; 561 $field_type = bp_xprofile_get_field_type( $field_id ); 562 563 // Check WordPress if it's a WordPress field. 564 if ( isset( $field_type->wp_user_key ) ) { 565 $meta = $field_type->get_field_value( $user_id, $field_id ); 566 $d->id = $meta['id']; 567 $d->value = $meta['value']; 568 $d->table_name = $meta['table_name']; 569 570 } else { 571 $d->id = ''; 572 $d->value = ''; 573 } 574 575 $d->table_name = ''; 529 576 $d->user_id = $id; 530 577 $d->field_id = $field_id; 531 $d->value = '';532 578 $d->last_updated = ''; 533 579 } … … 571 617 * 572 618 * @since 1.0.0 619 * @deprecated 8.0.0 This function is not used anymore. 573 620 * 574 621 * @param array|string $fields Field(s) to get. … … 577 624 */ 578 625 public static function get_value_byfieldname( $fields, $user_id = null ) { 626 _deprecated_function( __FUNCTION__, '8.0.0' ); 579 627 global $wpdb; 580 628
Note: See TracChangeset
for help on using the changeset viewer.