Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 134490

Mike Rodriguez on "global $post not working! Trying to get the post ID"

$
0
0

I'm running into an issue where i'm trying to get the Post ID while trying to hook into a plugin function(function is inside my functions.php file)

For some reason global $post is not working!

My objective is to store the current posts, post ID into a variable where after the quiz is done, it will update a custom field.

Here is my code below. I'm echoing the $post->ID; just to test, but I'm not getting anything back.

add_action('ssquiz_finished', 'after_quiz_done', 10, 4);

function after_quiz_done( $quiz_id, $user_id, $questions_right, $total_questions )
{
	global $post;

	echo $post->ID;

}

Any help would be greatly appreciated.


Viewing all articles
Browse latest Browse all 134490

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>