Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raviousprime/0247df63d7d9214e7d2470128b06c0cd to your computer and use it in GitHub Desktop.
Save raviousprime/0247df63d7d9214e7d2470128b06c0cd to your computer and use it in GitHub Desktop.
Add new field for confirm email field..
<?php
add_action( 'register_form', function () {
$confirm_user_email = '';
if ( isset( $_POST['confirm_user_email'] ) && is_string( $_POST['confirm_user_email'] ) ) {
$confirm_user_email = wp_unslash( $_POST['confirm_user_email'] );
}
?>
<p>
<label for="confirm_user_email"><?php _e( 'Confirm Email' ); ?></label>
<input name="confirm_user_email" type="email" id="confirm_user_email" class="input" value="<?php echo esc_attr( $confirm_user_email ); ?>" maxlength="200" />
</p>
<?php
} );
add_filter( 'registration_errors', function ( $errors, $user_login, $user_email ) {
if ( $errors->has_errors() ) {
return $errors;
}
if ( ! isset( $_POST['confirm_user_email'] ) || $user_email != wp_unslash( $_POST['confirm_user_email'] ) ) {
$errors->add( 'email_not_matched', __( 'Email not matched. Please check.' ) );
}
return $errors;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment