where and how to save additional information during registration

Question

i am creating a registration page but i want additional information to be save
(eg.address) during the registration not after i try this

if ( $_POST ) {

 $username = $_POST["user_name"];

 $first_name = $_POST["first_name"];
 $last_name = $_POST["last_name"];
 $email  = $_POST["email"];
 $password = $_POST["password"];
$confirm_password = $_POST["password_confirm"];
$address = $_POST['address'];

if( username_exists($username)){
    echo 'user name already exists';
}
wp_insert_user([
    'user_pass' => $password,
    'user_login' => $username,
    'user_email' => $email,
    'first_name' => $first_name,
    'last_name' => $last_name,
    'user_registered'   => date('Y-m-d H:i:s'),
    'role'              => 'subscriber'
]);

i don’t know how to save $address
i already use add_user_meta(); but it’s work when the user is registered and i don’t want that.
can anybody help with this.

0
deeeg 4 months 0 Answers 18 views 0

Leave an answer