Support » Plugin: Lightweight Contact Form » Uncaught ArgumentCountError: Too few arguments to function

  • NJ

    (@rgtbstbw45h54ty45y35)


    Great plugin. I can’t believe it’s so slim! But I’ve run into a problem with the custom form fields in testing. It’s throwing a 1 passed in C:\wamp64\www\test\wp-includes\class-wp-hook.php on line 287 and exactly 2 expected in C:\wamp64\www\test\wp-content\themes\test_theme\functions.php on line 98 Error on the [code]add_filter( 'lcf_additional_field_values', function( $val, $post_data ) {[/code] line.

    I’ve tried it on two different site installs with different themes and function sheets and I get the same error in both. It’s something to do with $value = call_user_func_array( $the_[‘function’], $args );

    I’m running these on localhost so I can’t provide a link.

Viewing 1 replies (of 1 total)
  • Hiya, I was having same problem so I edited the code a little to get it working. for any future people struggling with it, this is what i did.

    Swap out this function:

    /**
     * Add the radio field values to the email message
     */
    add_filter( 'lcf_additional_field_values', function( $val, $post_data ) {
        if ( ! empty( $post_data['lcf_contactform_refund'] ) ) {
            $new = 'Exchange or refund:  '. sanitize_text_field( $post_data['lcf_contactform_refund'] );
            return $new;
        } 
        return $val;
    }, 10, 2 );

    Replacing with this one:

    /**
     * Edited adding of the radio field values to the email message
     */
    add_filter( 'lcf_additional_field_values', function( $post_data ) {
        if ( ! empty( $_POST['your_field_name'] ) ) {
            $new = 'Exchange or refund: '. $post_data['your_field_name'];
    		$checker = sanitize_text_field($_POST['your_field_name']);
    		return $new . $checker;
    	    
       } 
    }, 10, 2 );

    Naturally, being sure to replace your-field-name throughout with whatever the name (not ID) of your radio–button field is.

    I don’t say it’s elegant, but it worked for me!

Viewing 1 replies (of 1 total)
  • The topic ‘Uncaught ArgumentCountError: Too few arguments to function’ is closed to new replies.