title: PHP global $post not working! Trying to get the post ID in WordPress
body: <p>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)</p>
  
  <p>For some reason <code>global $post</code> is not working!</p>
  
  <p>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.</p>
  
  <p>Here is my code below. I'm echoing the $post->ID; just to test, but I'm not getting anything back.</p>
  
  <pre><code>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-&gt;ID;
  
  }
  </code></pre>
  
  <p>Here is the actual 'ssquiz_finished' function/hook from the SS QUIZ plugin:</p>
  
  <pre><code>$output = ob_get_contents();
  ob_end_clean();
  $finish_screen .= $output;
  
  $temp = new stdClass();
  $temp-&gt;user_name = $info-&gt;user-&gt;name;
  $temp-&gt;user_email = $info-&gt;user-&gt;email;
  $temp-&gt;time_spent = time() - $info-&gt;started;
  $wpdb-&gt;insert("{$wpdb-&gt;base_prefix}ssquiz_history", 
                  array( 
                      'user_id' =&gt; $info-&gt;user-&gt;id,
                      'quiz_id' =&gt; $info-&gt;quiz-&gt;id,
                      'meta' =&gt; serialize( $temp ),
                      'answered'=&gt; $info-&gt;questions_counter,
                      'correct' =&gt; $info-&gt;questions_right,
                      'total' =&gt; $info-&gt;total_questions
                  ), 
                  array( '%d', '%d', '%s', '%d', '%d', '%d' ) );
  
  if( $info-&gt;questions_counter == $info-&gt;total_questions ) {
      // API
      $percent = intval(strval($info-&gt;questions_right / $info-&gt;questions_counter * 100 ) ); //$info-&gt;questions_counter !=1
      do_action( 'ssquiz_finished', $info-&gt;quiz-&gt;id, $info-&gt;user-&gt;id, $info-&gt;questions_right, $info-&gt;total_questions );
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>