Custom upload field in user profile
-
Hi all
I’m trying to add ‘doc’ filed upload as a custom user profile field.
In the functions.php I’ve added following code:function wp_save_custom_user_profile_fields( $user_id ) { if ( !current_user_can( 'edit_user', $user_id ) ) { return false; } $overrides = array( 'test_form' => false); $doc = wp_handle_upload( $_FILES['doc'] , $overrides ); update_user_meta( $user_id, 'doc', $doc); } add_action( 'personal_options_update', 'wp_save_custom_user_profile_fields' ); add_action( 'edit_user_profile_update', 'wp_save_custom_user_profile_fields' );
In the custom profile view I have added:
<label for="doc"><?php _e( 'Upload document' ) ?></label> <input type="file" name="doc" id="doc" value="" />
in the wp_usermeta table field is created, but all the time it shows error that file is emapty or I have disabled file upload possibility.
I’ve also added the ‘upload_files’ right to the user role.
- The topic ‘Custom upload field in user profile’ is closed to new replies.