save image in upload folder
-
Hi guys
i want to create a field in user profile to upload image for use in author page .
and so i write the following codes but image url insert in database but photo can not be saved in upload folder
please help me!add_action( 'show_user_profile', 'my_show_extra_profile_fields' ); add_action( 'edit_user_profile', 'my_show_extra_profile_fields' ); function my_show_extra_profile_fields( $user ) { ?> <h3>Extra profile information</h3> <table class="form-table"> <tr> <th><label for="Linkedin">Header Photo</label></th> <td> <input type="file" name="Header" id="Header" value="<?php echo esc_attr( get_the_author_meta( 'Header', $user->ID ) ); ?>" class="regular-text" /> <span class="description">عکس هدر صفحه پروفایل خود را آپلود کنید</span> </td> </tr> </table> <?php } add_action( 'personal_options_update', 'my_save_extra_profile_fields' ); add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' ); function my_save_extra_profile_fields( $user_id ) { $uploadUrl= wp_get_upload_dir(); if ( !current_user_can( 'edit_user', $user_id ) ) return false; /* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */ update_usermeta( $user_id, 'Header', $uploadUrl['url']."/".$_POST['Header'] ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘save image in upload folder’ is closed to new replies.