WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/add user meta

Contents

Description

Add metadata to a user's record.

Usage

<?php add_user_meta$user_id$meta_key$meta_value$unique ); ?>

Parameters

$user_id
(integer) (required) user ID
Default: None
$meta_key
(string) (required) Metadata name.
Default: None
$meta_value
(mixed) (required) Metadata value.
Default: None
$unique
(boolean) (optional) Whether the same key should not be added.
Default: false

Return Values

(integer/boolean) 
Primary key id for success. False for failure.

Examples

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

Notes

Change Log

Since: 3.0.0

Source File

add_user_meta() is located in wp-includes/user.php.

Related

add_user_meta(), delete_user_meta(), get_user_meta(), update_user_meta(), get_user_option(), delete_user_option(), update_user_option(),

See also index of Function Reference and index of Template Tags.