add_user_meta() wordpress function and usage This text is not used because the data attribute has a value

add_user_meta() wordpress function and usage

Home / WordPress / WordPress Wiki / add_user_meta() wordpress function and usage

add_user_meta( int $user_id, string $meta_key, mixed $meta_value, bool $unique = false )
Adds meta data to a user.

Parameters

$user_id

(int) (Required) User ID.

$meta_key

(string) (Required) Metadata name.

$meta_value

(mixed) (Required) Metadata value. Must be serializable if non-scalar.

$unique

(bool) (Optional) Whether the same key should not be added.

Default value: false

Return

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

Sample Usage

Examples

<?php
$user_id = 1;
$awesome_level = 1000;
add_user_meta( $user_id, '_level_of_awesomeness', $awesome_level);
?>

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments