在Wordpress中创建新用户时,更新usermeta中的'billing_phone'字段?

时间:2019-07-13 21:33:47

标签: php database woocommerce custom-wordpress-pages user-registration

我正在创建一个自定义用户注册表单,其中包含一些额外的字段,这些字段未包含在默认的wordpress注册表单中。因此,除“ billing_phone”外,所有字段都将值取值并将其插入数据库。我对此并不陌生。

我正在使用wp_insert_user()函数创建用户。

<?php
/*Template Name: Sign Up*/
?>


<?php
/*
Template name: Page - Full Width - Parallax Title
*/
get_header();

    global $wpdb;

if ( is_user_logged_in() ) {
    $location = get_site_url() . "/my-account";
    wp_redirect($location);
    exit;
}

$firstname = $wpdb->escape($_POST['firstname']);
$lastname = $wpdb->escape($_POST['lastname']);
$email = $wpdb->escape($_POST['email']);
$password = $wpdb->escape($_POST['password']);
$confirmpassword = $wpdb->escape($_POST['confirm-password']);
$mobile = $wpdb->escape($_POST['mobile']);

if (isset($_POST['submit'])) {

    $user = wp_insert_user([

        'first_name' => $firstname,
        'last_name' => $lastname,
        'user_login' => $email,
        'nickname'  => $firstname." ".$lastname,
        'user_email' => $email,
        'user_pass' =>  $password,
        'billing_phone' => $mobile,


    ]);

}

 ?>



    <div class="form_page_bgcolor">
    <div id="signUp_form">
        <h3 style="text-align:center;">SIGN UP WITH</h3>
    <form method="post" id="signupform">
    <div id="socialLogin">


        <a href="https://www.jbaat.com/y8jr9fznbzfqjnck/?                    loginFacebook=1&redirect=https%3A%2F%2Fwww.jbaat.com%2F"     class="facebooksignup">facebook</a> &nbsp&nbspOR&nbsp&nbsp
    <a href="https://www.jbaat.com/y8jr9fznbzfqjnck/?    loginGoogle=1&redirect=https%3A%2F%2Fwww.jbaat.com%2F"         class="googlesignup">Google+</a>
    </div>
    <h3 style="text-align:center;">OR REGISTER BELOW</h3>
    <label>*First Name</label>
    <input type="text" name="firstname" id="first_name">
    <label>*Last Name</label>
    <input type="text" name="lastname" id="last_name"><br>
    <label>*Email Address</label>
    <input type="email" name="email" id="email"><br>
    <div id="mblspan"><label>*Mobile Number</label><span>+91</span>
    <input type="tel" name="mobile" id="mobile"></div><br>
    <label>*Password</label>
    <input type="password" name="password" id="password"><br>
    <label>*Confirm Password</label>
    <input type="password" name="confirm-password" id="confirm-password"><br>
    <label>*Please answer 2 + 4 = ?</label><span></span><input type="number"     name="captcha" id="captcha"><br>
    <input type="submit" name="submit" id="submit" value="Sign Up">
<p>Already a member? Sign in.</p>
</form>
<div>
<div>
<?php get_footer(); ?>

我想了解为什么'billing_phone'不能像其他字段一样工作,如何解决?

0 个答案:

没有答案