SOLVED: Form filter validation bricks/form/validate give me error 500

Browser: Firefox
OS: macOS

I am trying to use the

add_filter( 'bricks/form/validate', function( $errors, $form )

with the sample code from the Form Element – Bricks Academy

but I am getting error 500

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function form_valida_honeypot(), 1 passed in /www/sito/wp-includes/class-wp-hook.php on line 310 and exactly 2 expected in /www/sito/wp-content/plugins/snd-custom/admin/post-type/post-type-contact-form.php:171
Stack trace:
#0 /www/sito/wp-includes/class-wp-hook.php(310): form_valida_honeypot(Array)
#1 /www/sito/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array)
#2 /www/sito/wp-content/themes/bricks/includes/integrations/form/init.php(83): apply_filters('bricks/form/val...', Array, Object(Bricks\Integrations\Form\Init))
#3 /www/sito/wp-includes/class-wp-hook.php(308): Bricks\Integrations\Form\Init->form_submit('')
#4 /www/sito/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array)
#5 /www/sito/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#6 /www/rober in /www/sito/wp-content/plugins/snd-custom/admin/post-type/post-type-contact-form.php on line 171

The sample code on the documentation page is wrong. You have to add the number of arguments to the add_filter call:

add_filter( 'bricks/form/validate', function( $errors, $form ) {
  ...
  ...
  ...
}, 10, 2 );

The , 10, 2 part at the end is the missing piece.

2 Likes

Thank you, it is working now! :love_you_gesture:

Hey Andres,

Thanks for the help.
Just amended the academy article.

Regards,
Jenn

2 Likes