Support » Developing with WordPress » How do I add custom user meta data

Viewing 3 replies - 1 through 3 (of 3 total)
  • I want the default value should be 0

    Hi @sunmoluvic,

    Refer link to add/update user meta data.

    Moderator bcworkz

    (@bcworkz)

    Dixita is correct, you use update_user_meta(). I wanted to add that all user meta is saved in the DB as varchar, so as a string value. PHP is a loosely typed language so in most cases you can perform arithmetic on numeric strings. If you encounter that rare case where type does matter, you can type cast values. For example:
    $result = (int) get_user_meta( $id, 'my_integer', true ) + 12;

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I add custom user meta data’ is closed to new replies.