WooCommerce:使用 URL 中的参数预填充注册字段

WooCommerce: pre populate registration fields with parameters from URL

我在我的网站上使用了一个小表格(Gravity Forms),它要求输入名字、姓氏和电子邮件。发送表单后,它会重定向到 WooCommerce 注册页面并向 URL.

添加一些参数

URL 看起来像这样:https://example.com/?first_name=First&last_name=Name&email=info%40example.com

现在我已经使用以下代码(对于电子邮件字段)更改了 WooCommerce 模板表单-login.php:

<?php $first_name = $_GET['first_name']; ?>
<?php $last_name = $_GET['last_name']; ?>
<?php $email = $_GET['email']; ?>

<div class="form-group">
    <label for="reg_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
    <input type="email" class="form-control" name="email" id="reg_email" value="<?php if ( ! empty( $_POST['email'] ) ) echo esc_attr( $_POST['email'] ); ?><?php if ( !empty($email) ) : echo $email; endif; ?>" placeholder="info@example.com" />
</div>

它适用于这个字段,因为我可以更改它。 (怎么做的好吗?)

问题是,我在模板中看不到名字和姓氏字段。 因此我不知道如何更改它们或添加参数。

有什么技巧吗?

我可以解决问题...我的错误!

我在本教程中添加了名字和姓氏字段:https://businessbloomer.com/woocommerce-add-first-last-name-account-register-form/

现在我可以像上面那样添加参数了。