• Resolved 1jd123

    (@1jd123)


    Dear All,

    i really enjoy the use of your plugin but i ran into a major issue.
    When i try to register a new user i get the error “An error occurred while processing the form. To specify, i only get this error message when i enter a non existent “username” in the field “Mitgliedsnummer”. When the username does exist in my db I get the error message from my hook and everything works fine.

    add_filter('forminator_custom_form_submit_errors', 'my_custom_form_validation', 10, 3);
    
    function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {
    
      // Skip if is not the correct form
      if( (int) $form_id !== 3256 ){
        return;
       }
        $field = $_POST['text-1'];
    $field2 = $_POST['address-1-zip'];
    $user = get_user_by( 'login', $field);
    $pass = wp_check_password($field2, $user->user_pass, $user->ID);
        if ( $user && $pass ) {
           
        } else {
            $submit_errors[][ 'text-1'] = __( 'Falsche Kombination aus Mitgliedsnummer und Postleitzahl' );
        }
    
     return $submit_errors;
    
    }
    ?>

    To help you test it you can use “BE00000002” as “Mitgliedsnummer” and “1234” as Postleitzahl. This will throw the intended error from the custom hook. But when i use “BE000002” as “Mitgliedsnummer which does not exist in my database it will throw “An error occurred while processing the form. Please try again.” instead of the intended error from the custom hook

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @1jd123,

    Could you please try this snippet instead and see whether it works:

    add_filter('forminator_custom_form_submit_errors', 'my_custom_form_validation', 10, 3);
    
    function my_custom_form_validation($submit_errors, $form_id, $field_data_array) {
    
        // Skip if is not the correct form
        if( (int) $form_id !== 3256 ){
            return;
        }
        $pass = '';
        $field = $_POST['text-1'];
        $field2 = $_POST['address-1-zip'];
        $user = get_user_by( 'login', $field);
        if( $user ){
            $pass = wp_check_password($field2, $user->user_pass, $user->ID);
        }
        if ( $user && $pass ) {
           return $submit_errors;
        } else {
            $submit_errors[][ 'text-1'] = __( 'Falsche Kombination aus Mitgliedsnummer und Postleitzahl' );
        }
        
        return $submit_errors;
    }

    Please do let us know how that goes.

    Kind Regards,
    Nithin

    Thread Starter 1jd123

    (@1jd123)

    Hey Nithin ,

    works like a charm thank you so much!

    Have a great one!

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @1jd123

    I’m glad that this issue is resolved.

    If you have a moment, I would very much appreciate it if you could quickly rate our plugin. This will help us keep the plugin available for free.

    https://www.ads-software.com/support/plugin/forminator/reviews/#new-post

    Best Regards
    Patrick Freitas

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘An error occurred while processing the form. Please try again.’ is closed to new replies.