Ipstenu (Mika Epstein) on "save image in upload folder"

ساخت وبلاگ

omidparkour
Member
Posted 10 hours ago #

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 ) )
retu 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'] );
}

Please don't post in the Alpha/Beta forum unless you're actually testing the alpha/beta version of WordPress (not a plugin or a theme). Also, once WordPress has released a version, it's not appropriate to post in alpha/beta and you should post in the How To & Troublshooting forum:

https://wordpress.org/support/forum/how-to-and-troubleshooting

This post has been moved out for you.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 312 تاريخ : شنبه 15 خرداد 1395 ساعت: 3:51