Problem:
A custom Toolset user field (wpcf-number-of-bookings) was initialized with a value of 0 when a user was created. However, when editing and saving the user from WordPress Dashboard → Edit User, the value 0 was cleared and saved as empty, even when the field type was set as a single-line text or number field. This behavior occurred consistently across multiple sites.
Solution:
A PHP hook was added to listen to the profile_update action. After the user profile is saved, the code checks whether the custom user meta field is empty or null. If so, it explicitly resets the value back to "0" using update_user_meta(). This ensures that zero values persist after saving the user profile in the WordPress admin.
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/creating-custom-user-profiles/
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.
This topic contains 1 reply, has 1 voice.
Last updated by 1 month, 3 weeks ago.
Assisted by: Christopher Amirian.