[user_meta key="image" show="id"]It is set well, but when I submit the form, the default value of image field has gone, and the validation is failed. How can I succeed that? Should I put some php code sniphet?
If I;m right so far, then the problem is the key you are passing to the shortcode. The name of your user meta field is "image–user". The key is the name of the user meta field. You are passing "image" instead of "image-user".
Your use of show="id" is puzzling in the user meta data context. The user_meta shortcode retrieves user meta values from the wp_usermeta table. WordPress stores each field of user meta as key/value pairs. The "key" that you pass through the shortcode is used as a search string for the meta_key field in the wp_usermeta table. The shortcode retrieves that meta_value tied to the meta_key. show="id" does nothing in this case and may even break the shortcode.
If there has been no image uploaded or you are testing the form without having an image uploaded, there is no value for the file upload field. Empty fields are not stored in the database, so there won't be a user meta field for that user.
<p>I'll explain it in detail. I set up the file upload field on the user registration form, and connect user meta to it with key named "portrait". Next I made another form and added the file upload field with default value `[user_meta key=portrait show=id]`. It printed actual media id, but when I hit the submit button, the default value was vanished. What is the mechanism of retrieving the default value of the file upload field?</p>
Why do you need a file upload field on the second form?
I can't talk about that because it is a business secret. I only say it is for auto population of the other form.
Please login or Register to submit your answer
I completely solved it thanks to Toyin.