Below is the code that adds a new field to the registration form. How can I add it handling when the registration button is pressed, that if the passwords don’t match, it shows an error and doesn’t query the database. I would also be grateful for materials that can understand, with examples, which elements can be created and where their handlers are.
add_filter( 'hivepress/v1/forms/user_register', 'custom_add_password_confirmation_field' );
function custom_add_password_confirmation_field( $form ) {
$form['fields']['password_confirmation'] = [
'required' => true,
'_order' => 30,
'label' => __( 'Confirm Password', 'text-domain' ),
'type' => 'password',
'attributes' => [
'autocomplete' => 'new-password',
],
];
return $form;
}