XProfile_Data::get( $args, $assoc_args )
Get profile data for a user.
Contents
Description Description
OPTIONS OPTIONS
–user-id=
[–field-id=
[–format=] : Render output in a particular format. [–format=] : Render output in a particular format.
default: table options:
[–multi-format=] : The format for the array data. [–multi-format=] : The format for the array data.
default: array options:
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 ); } }
Expand full source code Collapse full source code View on Trac