How add error message to register button

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;
}

Hi,

We recommend that you familiarize yourself with the code samples - Search · user:hivepress · GitHub. You can also check out these links:

​I hope this is helpful to you.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.