Gform_after_submission not executed after submit (GFCommon::log_debug also not visible) [RESOLVED]

I’m developing a custom plugin inside this plugin i have developed some classes that need to do some data handling after a submission.

What I have tried is adding the gform_after_submission action, and hooked it with a function. Inside this function I’m running GFCommon::log_debug text for output a custom text to debugging file. But this output is not showing inside the log?

Example of the current code (without the class, only the add_action and function):

add_action('gform_after_submission', 'gf_registration_form_payment_validation', 10, 2);
function gf_registration_form_payment_validation($entry, $form) {
   \GFCommon::log_debug('Form debug data:');
   \GFCommon::log_debug($entry);
}

On several forums they are saying that the add_action hook needs to run before the gform_after_submission will be loaded? I have tried it with priority change but no success.

Hope somebody can help me further, thanks!

Hello. I can tell you that gform_after_submission is pretty reliable - it runs after submission every time. You have the priority and the parameters correct, so there is probably something else going on with your code or your site.

Do you have Gravity Forms logging enabled already?

What is your Gravity Forms version?

If your Gravity Forms version is 2.2 or later, logging is built in to Gravity Forms core without any additional plugin. Documentation for Enabling Logging: Logging and Debugging - Gravity Forms Documentation

If logging is enabled, and you are using a recent Gravity Forms version, this will run when any Gravity Forms form is submitted:

add_action( 'gform_after_submission', 'gf_registration_form_payment_validation', 10, 2 );
function gf_registration_form_payment_validation( $entry, $form ) {
	GFCommon::log_debug( __METHOD__ . '(): running.' );
	GFCommon::log_debug( __METHOD__ . '(): The Entry => ' . print_r( $entry, true ) );
}

This will run when form 9 is submitted:

add_action( 'gform_after_submission_9', 'gf_registration_form_payment_validation', 10, 2 );
function gf_registration_form_payment_validation( $entry, $form ) {
	GFCommon::log_debug( __METHOD__ . '(): running.' );
	GFCommon::log_debug( __METHOD__ . '(): The Entry => ' . print_r( $entry, true ) );
}

Hello Chris and readers,

Thank you for the detailed explanation.

Logging has been enabled and I’m using the latest version of GravityForms (2.5.16), the code explanation and what you are suggesting that’s what im currently doing also. Or I might not see what I’m doing wrong :).

I have transferred my code to a public repository and changed some classnames to make it more readable. The repository location: GitHub - basewire/gf_example_plugin

The function where i’m running the action gform_after_submission can be found here: gf_example_plugin/registration-form.php at master · basewire/gf_example_plugin · GitHub

Hope somebody (Chris, or anybody who reads this) can help me further, thanks!

Ok, i have readed over and over it that made me blind :see_no_evil: of the situation. The solution for my issue is:

Old and wrong situation:
add_action('gform_after_submission', [$this, 'gform_after_submission_function', 10, 2]);

Needs to be transformed to:
add_action('gform_after_submission', [$this, 'gform_after_submission_function'], 10, 2);

The priority and the accepted_args needs to be out the function $this. This made the function not load when the gform_after_submission hook will be fired.

1 Like