Unable to get post id inside ‘ninja_forms_after_submission’ callback
-
I am rendering Ninja Forms dynamically. By dynamically I mean the shortcode is coming from an ACF field, so at different pages, there would be different forms or multiple different/same forms on the same page. So it is like:
if ($nf_shortcode && $a_condtion){ echo do_shortcode($nf_shortcode); //Render Ninja Form }
I am using
ninja_forms_after_submission
hook like this:add_action('ninja_forms_after_submission', 'my_ninja_forms_after_submission' ); function my_ninja_forms_after_submission( $form_data ){ $form_id = $form_data['form_id']; /* global $wp_query; $post_id = $post->ID; //This never returns a valid ID. */ }
$post_id
in this block always return 0 or nothing. Triedget_queried_object_id()
as well but no luck.
Another issue is that within this function,wp_redirect()
is not working. It is getting quite frustrating that why these basic functions are not working inside this hook callback.
Any help would be appreciated.
Thank you
- The topic ‘Unable to get post id inside ‘ninja_forms_after_submission’ callback’ is closed to new replies.