PHP Class User_Meta_Command, wp-cli

## EXAMPLES # Add user meta $ wp user meta add 123 bio "Mary is an WordPress developer." Success: Added custom field. # List user meta $ wp user meta list 123 --keys=nickname,description,wp_capabilities +---------+-----------------+--------------------------------+ | user_id | meta_key | meta_value | +---------+-----------------+--------------------------------+ | 123 | nickname | supervisor | | 123 | description | Mary is a WordPress developer. | | 123 | wp_capabilities | {"administrator":true} | +---------+-----------------+--------------------------------+ # Update user meta $ wp user meta update 123 bio "Mary is an awesome WordPress developer." Success: Updated custom field 'bio'. # Delete user meta $ wp user meta delete 123 bio Success: Deleted custom field.
Inheritance: extends WP_CLI\CommandWithMeta
Mostrar archivo Open project: wp-cli/wp-cli

Protected Properties

Property Type Description
$meta_type

Public Methods

Method Description
__construct ( )
add ( $args, $assoc_args ) Add a meta field.
delete ( $args, $assoc_args ) Delete a meta field.
get ( $args, $assoc_args ) Get meta field value.
list_ ( $args, $assoc_args ) List all metadata associated with a user.
update ( $args, $assoc_args ) Update a meta field.

Private Methods

Method Description
replace_login_with_user_id ( $args ) : array Replace user_login value with user ID user meta is a special case that also supports user_login

Method Details

__construct() public method

public __construct ( )

add() public method

## OPTIONS : The user login, user email, or user ID of the user to add metadata for. : The metadata key. : The new metadata value. [--format=] : The serialization format for the value. Default is plaintext. ## EXAMPLES # Add user meta $ wp user meta add 123 bio "Mary is an WordPress developer." Success: Added custom field.
public add ( $args, $assoc_args )

delete() public method

## OPTIONS : The user login, user email, or user ID of the user to delete metadata from. : The metadata key. [] : The value to delete. If omitted, all rows with key will deleted. ## EXAMPLES # Delete user meta $ wp user meta delete 123 bio Success: Deleted custom field.
public delete ( $args, $assoc_args )

get() public method

## OPTIONS : The user login, user email, or user ID of the user to get metadata for. : The metadata key. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - yaml --- ## EXAMPLES # Get user meta $ wp user meta get 123 bio Mary is an WordPress developer.
public get ( $args, $assoc_args )

list_() public method

## OPTIONS : The user login, user email, or user ID of the user to get metadata for. [--keys=] : Limit output to metadata of specific keys. [--fields=] : Limit the output to specific row fields. Defaults to id,meta_key,meta_value. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - count - yaml --- ## EXAMPLES # List user meta $ wp user meta list 123 --keys=nickname,description,wp_capabilities +---------+-----------------+--------------------------------+ | user_id | meta_key | meta_value | +---------+-----------------+--------------------------------+ | 123 | nickname | supervisor | | 123 | description | Mary is a WordPress developer. | | 123 | wp_capabilities | {"administrator":true} | +---------+-----------------+--------------------------------+
public list_ ( $args, $assoc_args )

update() public method

## OPTIONS : The user login, user email, or user ID of the user to update metadata for. : The metadata key. : The new metadata value. [--format=] : The serialization format for the value. Default is plaintext. ## EXAMPLES # Update user meta $ wp user meta update 123 bio "Mary is an awesome WordPress developer." Success: Updated custom field 'bio'.
public update ( $args, $assoc_args )

Property Details

$meta_type protected_oe property

protected $meta_type