Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Dokan多供应商向注册添加自定义字段_Php_Wordpress - Fatal编程技术网

Php Dokan多供应商向注册添加自定义字段

Php Dokan多供应商向注册添加自定义字段,php,wordpress,Php,Wordpress,我正在尝试向Dokan供应商注册表单添加2个自定义字段,输入限制为15个字符。我是wordpress的新手,对如何编写代码知之甚少。我需要代码方面的帮助,可以帮助我做到这一点 我参考了其他论坛,并更改了Dokan Seller-registration-form.php以包含这些字段,但它们没有保存在Dokan供应商配置文件设置以及wordpress后端中 这些字段也需要在wordpress的管理后端更新 我尝试了堆栈中的以下链接作为解决方案。 我遗漏了一些我不知道需要修改的地方 我感谢你的帮

我正在尝试向Dokan供应商注册表单添加2个自定义字段,输入限制为15个字符。我是wordpress的新手,对如何编写代码知之甚少。我需要代码方面的帮助,可以帮助我做到这一点

我参考了其他论坛,并更改了Dokan Seller-registration-form.php以包含这些字段,但它们没有保存在Dokan供应商配置文件设置以及wordpress后端中

这些字段也需要在wordpress的管理后端更新

我尝试了堆栈中的以下链接作为解决方案。

我遗漏了一些我不知道需要修改的地方

我感谢你的帮助。如果你需要更多的细节,请告诉我

问候
Abhilash

这里我将展示如何在注册表中添加额外字段。[不带输入限制] 在执行此过程之前,您需要一个子主题。如果您已经安装了一个子主题,那么您可以通过它覆盖卖家注册表单。 请在子主题中创建一个名为dokan的文件夹,然后在名为global的dokan文件夹中创建另一个文件夹。现在,从wp-content/plugins/dokan-lite/templates/global文件夹复制seller-registration-form.php文件,并将其粘贴到子主题中

现在,从您的子主题打开seller-registration-form.php文件,并在您想要的位置上添加额外的字段,如下所示-

如果您只想复制和粘贴(GST编号字段),可以使用此代码-

*


请试着把你的问题分成几个小部分。要在这里提问,您需要提供更多的细节,包括更通用的技术。请编辑你的问题,否则有人会投反对票:)嗨,拉梅什…谢谢你的反馈…这是我第一次参加这样的技术论坛。我已经按照你的建议进行了编辑。阿比拉什,请你清楚地告诉我们你想做什么,以及当你试图做的时候你面临的问题是什么。例如,不要谈论像Dokan这样的第三方插件,它不太常用,告诉我们使用该插件想要实现什么。然后,我们可能会帮助您使用或不使用该插件。我想,您可能正在按照博客上的说明,如何向该表单添加一些自定义字段。如果是的话,现在告诉我们你已经做了哪些步骤,你在哪里卡住了。告诉我们您希望程序的行为是什么,以及您看到的意外情况。您还可以在wordpress中启用调试,然后告诉我们您看到的错误
<p class="form-row form-group form-row-wide">
    <label for="shop-phone"><?php esc_html_e( 'GST Number', 'dokan-custom-codes' ); ?> 
<span class="required">*</span></label>
    <input type="text" class="input-text form-control" name="gst_id" id="gst_id" value="<?php if ( ! empty( $postdata['gst_id'] ) ) echo esc_attr($postdata['gst_id']); ?>" required="required" />
</p>
function dokan_custom_seller_registration_required_fields( $required_fields ) {
$required_fields['gst_id'] = __( 'Please enter your GST number', '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 );

$gst_id =  $post_data['gst_id'];

update_user_meta( $vendor_id, 'dokan_custom_gst_id', $gst_id );
}

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, 'dokan_custom_gst_id', true );
 ?>
     <tr>
                <th><?php esc_html_e( 'Gst Number', 'dokan-lite' ); ?></th>
                <td>
                    <input type="text" name="gst_id" class="regular-text" value="<?php 
echo esc_attr($gst); ?>"/>
                </td>
     </tr>
  <?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, 'dokan_custom_gst_id', $_POST['gst_id'] );
}