add_user_meta( int $user_id, string $meta_key, mixed $meta_value, bool $unique = false ): int|false

Adds meta data to a user.

Parameters

$user_idintrequired
User ID.
$meta_keystringrequired
Metadata name.
$meta_valuemixedrequired
Metadata value. Must be serializable if non-scalar.
$uniquebooloptional
Whether the same key should not be added.

Default:false

Return

int|false Meta ID on success, false on failure.

Source

function add_user_meta( $user_id, $meta_key, $meta_value, $unique = false ) {
	return add_metadata( 'user', $user_id, $meta_key, $meta_value, $unique );
}

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

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