问题描述
我正在尝试为供应商在 dokan 注册中添加一个额外的字段以上传身份证明文件。我将输入类型从“文本”更改为“文件”
<p class="form-row form-group form-row-wide">
<label for="veri-file"><?PHP esc_html_e( 'Upload Verification ID','dokan-custom-codes' ); ?><span class="required">*</span></label>
<input type="file" class="verifile" name="veri_file" id="veri_file" accept="image/png,image/jpeg" value="upload"<?PHP if ( ! empty( $postdata['veri_file'] ) ) echo esc_attr($postdata['veri_file']); ?>" required="required" />
</p>
那行得通……但是在用户后端保存和显示字段内容的代码并没有只显示同一个上传框的图像
//保存id验证字段
function dokan_custom_seller_registration_required_fields( $required_fields ) {
$required_fields['veri_file'] = __( 'Please upload a valid means of Identification','dokan-custom' );
return $required_fields;
};
add_filter( 'dokan_seller_registration_required_fields','dokan_custom_seller_registration_required_fields' );
function dokan_custom_new_seller_created( $vendor_id,$dokan_settings ) {
$post_data = wp_unslash( $_POST );
$veri_file = $post_data['veri_file'];
update_user_Meta( $vendor_id,'dokan_custom_veri_file',$veri_file );
}
add_action( 'dokan_new_seller_created','dokan_custom_new_seller_created',10,2 );
/* Add custom profile fields (call in theme : echo $curauth->fieldname;) */
add_action( 'dokan_seller_Meta_fields','my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<?PHP if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}
if ( ! user_can( $user,'dokandar' ) ) {
return;
}
$gst = get_user_Meta( $user->ID,true );
?>
<tr>
<th><?PHP esc_html_e( 'Upload Verification ID','dokan-lite' ); ?></th>
<td>
<input type="file" name="veri_file" class="verifile" value="<?PHP echo esc_attr($gst); ?>"/>
<img src=".$gst." height=200 width=300 />
</td>
</tr>
echo "<img src=".$gst." height=200 width=300 />";
<?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 ) {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}
update_userMeta( $user_id,$_POST['veri_file'] );
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)