BP_REST_XProfile_Field_Groups_Endpoint::get_xprofile_field_group_object( WP_REST_Request $request )

Get XProfile field group object.

Description

Parameters

$request

(Required) Full details about the request.

Return

(BP_XProfile_Group|string) XProfile field group object.

Source

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

	public function get_xprofile_field_group_object( $request ) {
		$profile_group_id = is_numeric( $request ) ? $request : (int) $request['id'];

		$args = array(
			'profile_group_id'       => $profile_group_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;
	}

Changelog

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.