BP_REST_XProfile_Fields_Endpoint::get_profile_field_rendered_value( string $value = '', integer|BP_XProfile_Field $profile_field = null )
Retrieve the rendered value of a profile field.
Description
Parameters
- $value
-
(string) (Optional) The raw value of the field.
Default value: ''
- $profile_field
-
(integer|BP_XProfile_Field) (Optional) The ID or the full object for the field.
Default value: null
Return
(string) The field value for the display context.
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php
public function get_profile_field_rendered_value( $value = '', $profile_field = null ) { if ( empty( $value ) ) { return ''; } $profile_field = xprofile_get_field( $profile_field ); if ( ! isset( $profile_field->id ) ) { return ''; } // Unserialize the BuddyPress way. $value = bp_unserialize_profile_field( $value ); global $field; $reset_global = $field; // Set the $field global as the `xprofile_filter_link_profile_data` filter needs it. $field = $profile_field; /** * Apply Filters to sanitize XProfile field value. * * @param string $value Value for the profile field. * @param string $type Type for the profile field. * @param int $id ID for the profile field. * * @since 0.1.0 */ $value = apply_filters( 'bp_get_the_profile_field_value', $value, $field->type, $field->id ); // Reset the global before returning the value. $field = $reset_global; return $value; }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.