Saving JSON data as meta_value for users in the wp_usermeta table. The JSON data looks something like this:
{
"user":5,
"levels":{
"1":{"first_seen":1614309493,"last_seen":1617368469},
"2":{"first_seen":1616309493,"last_seen":1617369479},
"3":{"first_seen":1617309493,"last_seen":1617379121}
}
}
The "first_seen" value (per level/id) should not change once it has a value saved. The "last_seen" value should be updated each time.
I am using this to save the data when a hook is fired. This - saving data per user, when no data is saved yet, works. BUT updating only the "last_seen" value once a user already has data, is something I am struggling with.
Is it even possible with "add_user_meta" and/or "update_user_meta" to the partly update a value? If not, are there any other solutions to get this working?
I am pretty sure I saw a plugin that handled this by using JSON, but can´t remember the name...
Hope you can help me out! Thanks a lot.