XProfile_Data::set( $args, $assoc_args )
Set profile data for a user.
Description Description
OPTIONS OPTIONS
–user-id=
–field-id=
–value=
EXAMPLE EXAMPLE
$ wp bp xprofile data set --user-id=45 --field-id=120 --value=teste
Success: Updated XProfile field "Field Name" (ID 120) with value "teste" for user user_login (ID 45).
Source Source
File: cli/src/xprofile-data.php
public function set( $args, $assoc_args ) { $user = $this->get_user_id_from_identifier( $assoc_args['user-id'] ); $field_id = $this->get_field_id( $assoc_args['field-id'] ); $field = new \BP_XProfile_Field( $field_id ); if ( empty( $field->name ) ) { WP_CLI::error( 'XProfile field not found.' ); } $value = $assoc_args['value']; if ( 'checkbox' === $field->type ) { $value = explode( ',', $assoc_args['value'] ); } $updated = xprofile_set_field_data( $field->id, $user->ID, $value ); if ( ! $updated ) { WP_CLI::error( 'Could not set profile data.' ); } WP_CLI::success( sprintf( 'Updated XProfile field "%s" (ID %d) with value "%s" for user %s (ID %d).', $field->name, $field->id, $assoc_args['value'], $user->user_nicename, $user->ID ) ); }
Expand full source code Collapse full source code View on Trac