Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#49809 closed defect (bug) (invalid)

Add user meta is saving more values

Reported by: egyptimhotep Owned by:
Priority: normal Milestone:
Component: Options, Meta APIs Version:
Severity: normal Keywords:
Cc: Focuses:

Description

On single.php place this function and open single post, meta is working fine, "fero" is saved one time. Then open another blog post, you will see that now it save two times same value "fero".

I believe it should save only one value to array.

<?php
add_user_meta(get_current_user_id(),'video_history',"fero");

Change History (3)

#1 @davidbaumwald
7 years ago

  • Component General → Options, Meta APIs
  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → closed

Hello, @egyptimhotep! Trac is for reporting bugs in WordPress Core, and this is actually a support issue. That being said, try using ​https://developer.wordpress.org/reference/functions/update_user_meta/ instead.

If you have any further issues, try asking over at the support forums ​https://wordpress.org/support/forums/.

#2 @knutsp
7 years ago

Hello @egyptimhotep

This is the expected behaviour. You may either supply en extra parameter $unique and set it to true, or use ´update_user_meta()´. Documented here ​https://developer.wordpress.org/reference/functions/add_user_meta/ and ​https://developer.wordpress.org/reference/functions/update_user_meta/

#3 @egyptimhotep
7 years ago

Guys, I am very sorry. My bad.
Thank you for support.

Version 0, edited 7 years ago by egyptimhotep (next)
Note: See TracTickets for help on using tickets.