My site allows user registration and requires users to upload documents to verify themselves. For this (and other user data) I added various user fields on the WordPress backend.

At registration I run update_user_meta() several times to save the values from the registration form. Like this:

update_user_meta( $user_id, 'phone_number', $phone_number );

This works great for normal values, but it fails me with the file uploads.

My file upload field allows the upload of several pdf documents and then returns them as an array. If I pass the result from that field similarly to the above phone number example the backend field just shows Array.

It would be ideal to have a separate field in the backend to display each file URL separately. To do this, I tried to build various sorts of for loops, but all of them so far have resulted in errors.

I'm not really sure how else to approach this...


In parameter $isSingle 3th of function get_user_meta default value is false and this return value with array.Change 3th parameter to true.

More details https://codex.wordpress.org/Function_Reference/update_user_meta

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.