admin管理员组

文章数量:1134246

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 months ago.

Improve this question

I need to get form’s fields data of submitted/current form on form submission

I trying with these hooks forminator_form_after_handle_submit/forminator_form_after_save_entry

trying this

add_action( ‘forminator_form_after_save_entry’, ‘function_Name’ );
function function_Name( $form_id, $response ) {
  // code here
}

but when submitting form get this issue

An error occurred while processing the form. Please try again

log error

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function function_Name(), 1 passed in D:\xampp\htdocs\sos_wp\wp-includes\class-wp-hook.php on line 312 and exactly 2 expected in D:\xampp\htdocs\sos_wp\wp-content\themes\sos-theme\functions.php:86

can someone help with this Thanks Dinesh

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 months ago.

Improve this question

I need to get form’s fields data of submitted/current form on form submission

I trying with these hooks forminator_form_after_handle_submit/forminator_form_after_save_entry

trying this

add_action( ‘forminator_form_after_save_entry’, ‘function_Name’ );
function function_Name( $form_id, $response ) {
  // code here
}

but when submitting form get this issue

An error occurred while processing the form. Please try again

log error

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function function_Name(), 1 passed in D:\xampp\htdocs\sos_wp\wp-includes\class-wp-hook.php on line 312 and exactly 2 expected in D:\xampp\htdocs\sos_wp\wp-content\themes\sos-theme\functions.php:86

can someone help with this Thanks Dinesh

Share Improve this question asked Sep 14, 2023 at 16:19 DineshDinesh 1457 bronze badges 1
  • Questions about 3rd party plugins are offtopic here and not in this stacks scope, if you need help developing for a plugin you downloaded/bought you need to ask elsewhere. You're lucky the cause of this is a mistake with add_action – Tom J Nowell Commented Sep 14, 2023 at 16:47
Add a comment  | 

2 Answers 2

Reset to default 3

I did some more research & find this can get form feilds with $_POST

add_action( 'forminator_form_after_handle_submit', 'function_Name', 10, 2 );
add_action( 'forminator_form_after_save_entry', 'function_Name', 10, 2 );

function function_Name($form_id, $response) {
    if( $response['success'] ){
        error_log(print_r($_POST, true));
    }
}

While I can't comment on Forminator on this stack, there is a basic mistake involving add_action causing the error message in your log.

The cause of this is that your function requires 2 arguments to work, but you did not tell add_action this, so it used the default 1:

add_action( string $hook_name, callable $callback, int $priority = 10, int $accepted_args = 1 ): true

https://developer.wordpress.org/reference/functions/add_action/

You need to specify that your function takes 2 arguments when using add_action using the 4th argument, e.g.

add_action( ‘test_action’, ‘callback’, 10, 2 );

Additionally, the quotation marks in the code in your question are using smart quotes ‘...’, use "..." or '...' instead

本文标签: Get form fields data on form submission using forminator plugin