[wp-trac] [WordPress Trac] #35337: Global $post is null in "comment_post" and "pre_comment_on_post" hooks

WordPress Trac noreply at wordpress.org
Thu Jan 7 00:38:09 UTC 2016


#35337: Global $post is null in "comment_post" and "pre_comment_on_post" hooks
--------------------------+-----------------------------
 Reporter:  dennis_f      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  4.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Since 4.4 when using the "comment_post" and "pre_comment_on_post" hooks,
 the global $post is null, you can test this with the following code:

 {{{#!php
 <?php
 add_action ('comment_post', 'my_comment_post_func', 10, 2);
 function my_comment_post_func($comment_ID, $comment_approved ){
         global $post;
         // $post is NULL here
 }
 }}}

 I tested the same code snippet with 4.3 and $post is set correctly in
 there

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35337>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list