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):
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.
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:
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
Ok, i have readed over and over it that made me blind 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.