xprofile_get_field( int|object $field, int|null $user_id = null, bool $get_data = true )
Get a profile field object.
Description Description
Parameters Parameters
- $field
-
(Required) ID of the field or object representing field data.
- $user_id
-
(Optional) ID of the user associated with the field. Ignored if
$get_data
is false. If$get_data
is true, but no$user_id
is provided, defaults to logged-in user ID.Default value: null
- $get_data
-
(Optional) Whether to fetch data for the specified
$user_id
.Default value: true
Return Return
(BP_XProfile_Field|null) Field object if found, otherwise null.
Source Source
File: bp-xprofile/bp-xprofile-functions.php
function xprofile_get_field( $field, $user_id = null, $get_data = true ) { if ( $field instanceof BP_XProfile_Field ) { $_field = $field; } elseif ( is_object( $field ) ) { $_field = new BP_XProfile_Field(); $_field->fill_data( $field ); } else { $_field = BP_XProfile_Field::get_instance( $field, $user_id, $get_data ); } if ( ! $_field ) { return null; } return $_field; }
Changelog Changelog
Version | Description |
---|---|
2.8.0 | Added $user_id and $get_data parameters. |
1.1.0 | Introduced. |