BP_REST_XProfile_Field_Groups_Endpoint::get_xprofile_field_group_object( WP_REST_Request $request )

Get XProfile field group object.


Parameters Parameters

$request

(WP_REST_Request) (Required) Full details about the request.


Top ↑

Return Return

(BP_XProfile_Group|string) XProfile field group object.


Source Source

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

	public function get_xprofile_field_group_object( $request ) {
		if ( is_numeric( $request ) ) {
			$args = array(
				'profile_group_id' => $request,
			);
		} else {
			$args = array(
				'profile_group_id'       => (int) $request['id'],
				'user_id'                => $request['user_id'],
				'member_type'            => $request['member_type'],
				'hide_empty_fields'      => $request['hide_empty_fields'],
				'fetch_fields'           => $request['fetch_fields'],
				'fetch_field_data'       => $request['fetch_field_data'],
				'fetch_visibility_level' => $request['fetch_visibility_level'],
				'exclude_fields'         => $request['exclude_fields'],
				'update_meta_cache'      => $request['update_meta_cache'],
			);

			if ( empty( $request['member_type'] ) ) {
				$args['member_type'] = null;
			}

			if ( empty( $request['exclude_fields'] ) ) {
				$args['exclude_fields'] = false;
			}
		}

		$field_group = current( bp_xprofile_get_groups( $args ) );

		if ( empty( $field_group->id ) ) {
			return '';
		}

		return $field_group;
	}


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.