Changeset 12869 for trunk/src/bp-xprofile/bp-xprofile-functions.php
- Timestamp:
- 03/22/2021 07:45:24 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-functions.php
r12768 r12869 160 160 'textbox' => 'BP_XProfile_Field_Type_Textbox', 161 161 'telephone' => 'BP_XProfile_Field_Type_Telephone', 162 'wp-biography' => 'BP_XProfile_Field_Type_WordPress_Biography', 163 'wp-textbox' => 'BP_XProfile_Field_Type_WordPress_Textbox', 162 164 ); 163 165 … … 312 314 313 315 /** 316 * Get a profile Field Type object. 317 * 318 * @since 8.0.0 319 * 320 * @param int $field_id ID of the field. 321 * @return BP_XProfile_Field_Type|null Field Type object if found, otherwise null. 322 */ 323 function bp_xprofile_get_field_type( $field_id ) { 324 $field_type = null; 325 $field = xprofile_get_field( $field_id, null, false ); 326 327 if ( $field instanceof BP_XProfile_Field ) { 328 $field_type = $field->type_obj; 329 } 330 331 return $field_type; 332 } 333 334 /** 314 335 * Delete a profile field object. 315 336 * … … 463 484 } 464 485 465 $field = new BP_XProfile_ProfileData(); 466 $field->field_id = $field_id; 467 $field->user_id = $user_id; 468 469 // Gets un/reserialized via xprofile_sanitize_data_value_before_save(). 470 $field->value = maybe_serialize( $value ); 471 472 return $field->save(); 486 $field_args = compact( 'field_type_obj', 'field', 'user_id', 'value', 'is_required' ); 487 488 /** 489 * Return a WP_Error object or true to use your custom way of saving field values. 490 * 491 * @since 8.0.0 492 * 493 * @param boolean Whether to shortcircuit the $bp->profile->table_name_data table. 494 * @param array $field_args { 495 * An array of arguments. 496 * 497 * @type object $field_type_obj Field type object. 498 * @type BP_XProfile_Field $field Field object. 499 * @type integer $user_id The user ID. 500 * @type mixed $value Value passed to xprofile_set_field_data(). 501 * @type boolean $is_required Whether or not the field is required. 502 * } 503 */ 504 $retval = apply_filters( 'bp_xprofile_set_field_data_pre_save', false, $field_args ); 505 506 if ( is_wp_error( $retval ) ) { 507 return false; 508 } 509 510 if ( false === $retval ) { 511 $field = new BP_XProfile_ProfileData(); 512 $field->field_id = $field_id; 513 $field->user_id = $user_id; 514 515 // Gets un/reserialized via xprofile_sanitize_data_value_before_save(). 516 $field->value = maybe_serialize( $value ); 517 518 $retval = $field->save(); 519 } 520 521 return $retval; 473 522 } 474 523 … … 1358 1407 ); 1359 1408 } 1409 1410 /** 1411 * Returns the list of supporterd WordPress field meta keys. 1412 * 1413 * @since 8.0.0 1414 * 1415 * @return string[] List of supported WordPress user keys. 1416 */ 1417 function bp_xprofile_get_wp_user_keys() { 1418 return array_merge( 1419 array( 'first_name', 'last_name', 'user_url', 'description' ), 1420 array_keys( wp_get_user_contact_methods() ) 1421 ); 1422 }
Note: See TracChangeset
for help on using the changeset viewer.