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 Description


Parameters Parameters

$value

(Optional) The raw value of the field.

Default value: ''

$profile_field

(Optional) The ID or the full object for the field.

Default value: null


Top ↑

Return Return

(string) The field value for the display context.


Top ↑

Source Source

File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php

	public function get_profile_field_rendered_value( $value = '', $profile_field = null ) {
		if ( ! $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.
		 *
		 * @since 5.0.0
		 *
		 * @param string $value Value for the profile field.
		 * @param string $type  Type for the profile field.
		 * @param int    $id    ID for the profile field.
		 */
		$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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.