-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wp_sync...action hook not being executed as async #18
Comments
You need to change
to
|
Sorry that was a silly typo on my post which I have amended now. However I definitely have the above code in my theme's functions.php. The action still won't work with the right tag for action. I also tried the wp_async_save_post action variance of my above code, where I used below in my theme's function.php instead, but no expected log found when a post is saved (created or edited from admin), if I remove the wp_async_ prefix in the add_action it would work fine just like the Gravity Form after submission action, but it wouldn't run asynchronously and from this plugin. class GF_Async_Task extends WP_Async_Task {
protected $action = 'save_post';
protected function prepare_data($data){
return array(
'post_id' => $data[0]
);
}
protected function run_action() {
if( isset( $_POST[ 'post_id' ] ) && 0 < absint( $_POST[ 'post_id' ] ) ){
do_action( "wp_async_$this->action", $_POST[ 'post_id' ], get_post( $_POST[ 'post_id' ] ) );
}
}
}
function send_custom_notification($id) {
error_log("test", 3, $_SERVER['DOCUMENT_ROOT'] . "/GFTEST.log");
}
add_action('wp_async_save_post', 'send_custom_notification');
function my_init_gf_task() {
new GF_Async_Task();
}
add_action('plugins_loaded', 'my_init_gf_task'); |
Looking at the documentation of the GForm hook it looks like the first parameter is the So you have to change the way you are retrieving protected function prepare_data($data){
return array(
'post_id' => $data['post_id']
);
} |
Thanks but that is only for the save_post action example, not the GForm hook. The My 1st comment above has the full code for the GForm hook async attempt, which is still not working. Could I breakpoint and debug what is going on by stepping through in WP? protected function prepare_data($data) {
return array(
'entry' => $data[0],
'form' => $data[1]
);
} |
Okay, you are correct. I mixed both the examples. The |
Alright I have just added this in the plugin's class instead of functions.php. I shouldn't add this functionality in a theme anyway as it is not theme dependent. After posting the form, I was able to print the value of |
Ok the But not with a form that contains many fields (about 4 steps). Could that be because of a limit in the WP Async Task class specification? I have set the local server's php.ini with config post_max_size = 100M. The |
Hi there, this plugin seems useful, but doesn't work for me in WP v4.7.5.
I'm trying to get a action hook from another plugin running asynchronously. This is the action hook I'm trying to run asynchronously https://www.gravityhelp.com/documentation/article/gform_after_submission/
I tried to incorporate that hook using similar steps described in the plugin's Github readme.
To just test the gform_after_submission_19 (where form id=19) action this is what I have added in my theme's function.php after activating the TechCrunch's plugin
But when I post the gravity form the expected action send_custom_notification action is just not doing the log
What could be wrong?
I also tried to set the sslverify option to false in the the launch_on_shutdown method of WP_Async_Task class by the editing original plugin file wp-async-task.php. I may needed to do this as i'm working on localhost for now.
But still no luck, any help/tips will be much appreciated, thanks!
The text was updated successfully, but these errors were encountered: