XProfile_Data::get( $args,  $assoc_args )

Get profile data for a user.


Description Description

Top ↑

OPTIONS OPTIONS

–user-id= : Identifier for the user. Accepts either a user_login or a numeric ID.

[–field-id=] : Identifier for the field. Accepts either the name of the field or a numeric ID.

Top ↑

[–format=] : Render output in a particular format. [–format=] : Render output in a particular format.

default: table options:

Top ↑

[–multi-format=] : The format for the array data. [–multi-format=] : The format for the array data.

default: array options:

Top ↑

EXAMPLES EXAMPLES

$ wp bp xprofile data get --user-id=45 --field-id=120
$ wp bp xprofile data see --user-id=user_test --field-id=Hometown --multi-format=comma

Source Source

File: cli/src/xprofile-data.php

	public function get( $args, $assoc_args ) {
		$user = $this->get_user_id_from_identifier( $assoc_args['user-id'] );

		if ( isset( $assoc_args['field-id'] ) ) {
			$data = xprofile_get_field_data( $assoc_args['field-id'], $user->ID, $assoc_args['multi-format'] );
			WP_CLI::print_value( $data, $assoc_args );
		} else {
			$data           = \BP_XProfile_ProfileData::get_all_for_user( $user->ID );
			$formatted_data = array();

			foreach ( $data as $field_name => $field_data ) {
				// Omit WP core fields.
				if ( ! is_array( $field_data ) ) {
					continue;
				}

				$formatted_data[] = array(
					'field_id'   => $field_data['field_id'],
					'field_name' => $field_name,
					'value'      => wp_json_encode( maybe_unserialize( $field_data['field_data'] ) ),
				);
			}

			$format_args           = $assoc_args;
			$format_args['fields'] = array(
				'field_id',
				'field_name',
				'value',
			);

			$this->get_formatter( $format_args )->display_items( $formatted_data );
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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