#49809 closed defect (bug) (invalid)
Add user meta is saving more values
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Options, Meta APIs | Keywords: | |
Focuses: | Cc: |
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
@
4 years ago
- Component changed from General to Options, Meta APIs
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
#2
@
4 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
@
4 years ago
Guys, I am very sorry. My bad.
Thank you for support.
Version 0, edited 4 years ago
by
(next)
Note: See
TracTickets for help on using
tickets.
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/.