I have a project in which i made a custom registration page but the problem is that my password field value not added to the database while email and username properly added. I could not understand why password value not stored. this is my php code.
$pwd1 = $wpdb->escape(trim($_POST['pwd1']));
$pwd2 = $wpdb->escape(trim($_POST['pwd2']));
$first_name = $wpdb->escape(trim($_POST['first_name']));
$last_name = $wpdb->escape(trim($_POST['last_name']));
$email = $wpdb->escape(trim($_POST['email']));
$username = $wpdb->escape(trim($_POST['username']));
if( $email == "" || $pwd1 == "" || $pwd2 == "" || $username == "" || $first_name == "" || $last_name == "") {
$err = 'Please don\'t leave the required fields.';
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$err = 'Invalid email address.';
} else if(email_exists($email) ) {
$err = 'Email already exist.';
} else if($pwd1 <> $pwd2 ){
$err = 'Password do not match.';
} else {
$user_id = wp_insert_user( array ('user_login' => apply_filters('pre_user_user_login', $username), 'user_pass' => apply_filters('pre_user_user_pass', $pwd1 ), 'user_email' => apply_filters('pre_user_user_email', $email), 'role' => 'subscriber' ) );
if( is_wp_error($user_id) ) {
$err = 'Error on user creation.';
} else {
do_action('user_register', $user_id);
$success = 'You\'re successfully register';
}
}
this is my html code
<ul style="margin-left:100px;"type="disk">
<li><label style="margin-right:30px; margin-top:20px;">Username:</label>
<input type="text" id="username" name="username" required="required" <span id="msg_username"></span></li>
<li><label style="margin-right:30px;">First Name:</label>
<input type="text" name="first_name" ></li>
<li><label style="margin-right:30px;">Last Name:</label>
<input type="text" name="last_name" ></li>
<li><label style="margin-right:60px;">Email:</label>
<input type="text" name="email" ></li>
<li><label style="margin-right:30px;">Password:</label>
<input type="password" name="pwd1" ></li>
<li><label style="margin-right:30px;">Confirm Password:</label>
<input type="password" name="pwd2" ></li>
</ul>
please tell me what is wrong with this.