我为我的订阅者创建了额外的字段,其中一个是图像字段,所以他们可以将图像上载到他们的个人资料中。
我用ACF(高级自定义字段)创建了字段。
我有一个自定义的注册表单和一个自定义的编辑表单,以及常规的WordPress字段和额外的字段。一切都很完美。。。图像字段除外。
我不担心注册表,我接受用户在注册时不会上传图像,但我需要他们在编辑信息时能够编辑/上传图像。
附言(1):图像将被用作头像,我不会使用常规的WordPress头像
附言(2):我不会使用acf\\U表单(),因为我需要对表单的工作方式进行太多的编辑
Here is part of the code:
<label for="avatar_user"></label>
<input class="text-input" name="avatar_user" type="file" id="avatar_user" value="<?php the_author_meta( \'avatar_user\', $current_user->ID ); ?>" />
if ( !empty( $_POST[\'avatar_user\'] ) ) :
update_user_meta( $current_user->ID, \'avatar_user\', esc_attr( $_POST[\'avatar_user\'] ) );