• Resolved cvc1968

    (@cvc1968)


    I have a function set up in functions.php to process a field at submission. Specifically a hidden honeypot checkbox field. This is the code:

    
    add_action( 'af/form/submission', 'honeypot_check' );
    
    function honeypot_check($form, $fields, $args) {
    	$human = af_get_field( 'human' );
    	if ($human) {
    		die();
    	}
    }
    

    I got this from the af fields documentation.

    I’ve read this error has something to do with the upgrade from php 5.6 to php 7.2.

    Here is the complete error log:

    
    PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function honeypot_check(), 1 passed in /home/account12/public_html/wp-includes/class-wp-hook.php on line 288 and exactly 3 expected in /home/account12/public_html/wp-content/themes/mytheme/functions.php:1325
    Stack trace:
    #0 /home/account12/public_html/wp-includes/class-wp-hook.php(288): honeypot_check(Array)
    #1 /home/account12/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    #2 /home/account12/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #3 /home/account12/public_html/wp-content/plugins/advanced-forms/core/forms/forms-submissions.php(66): do_action('af/form/submiss...', Array, Array, Array)
    #4 /home/account12/public_html/wp-includes/class-wp-hook.php(284): AF_Core_Forms_Submissions->pre_form()
    #5 /home/account12/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
    #6 /home/account12/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #7 /home/account12/public_html/wp-setting in /home/account12/public_html/wp-content/themes/mytheme/functions.php on line 1325
    

    I am unable to determine why only 1 argument is being passed or which argument it is.

    Any guidance would be appreciated.

Viewing 1 replies (of 1 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    You need to specify the number of arguments when registering your action. Like this: add_action( 'af/form/submission', 'honeypot_check', 10, 3 );.

    Hope this helps!

Viewing 1 replies (of 1 total)

The topic ‘Uncaught ArgumentCountError’ is closed to new replies.