This question already has an answer here:
- add_user_meta() vs update_user_meta() 2 answers
I've been doing some WordPress development for the past few years and never really used the User Meta API within WordPress.
Now with one of my projects requiring to store data unique to a user, I needed to look into it.
One thing I've noticed when I looked at the database is that
add_user_meta just creates duplicates when there is already an existing one.
My question is, why does this not override any existing key? And we should check first if the Meta Key already exists and then use
update_user_meta? Therefore creating an extra custom function if you would like to overwrite this by default.