Problem: I'm trying to copy a custom field from a post into a user field. The field is an image field. When I check the copied value with update_user_meta, the value is serialized in the database. How should I copy the field value correctly without serialization?
In the user meta field:
a:1:{i:0;s:86:"https://my-site.com/wp-content/uploads/2019/10/my-photo.jpg";}
Solution: When using get_post_meta, the third parameter will influence the returned data type. Use true in the third parameter to return only the first value, and prevent this serialization.
$photo_membre = get_post_meta ($post_id, 'wpcf-photo-identite-membre', true); update_user_meta ($user_id, 'wpcf-photo', $photo_membre);
Relevant Documentation:
https://developer.wordpress.org/reference/functions/get_post_meta/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Dieses Thema enthält 4 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von vor 5 Jahren.
Assistiert von: Christian Cox.