[wp-trac] [WordPress Trac] #35541: $_POST['comment'] / $comment_content on add_action 'pre_comment_on_post'

WordPress Trac noreply at wordpress.org
Wed Jan 20 12:20:09 UTC 2016


#35541: $_POST['comment'] / $comment_content on add_action 'pre_comment_on_post'
-----------------------------+-----------------------------
 Reporter:  becki            |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Comments         |    Version:  4.4.1
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 This is a follow-up to #34059.

 hello there,
 just have a question regarding the new function
 wp_handle_comment_submission() introduced in wp v.4.4.0 and the do_action
 'pre_comment_on_post'

 i need to allow 'empty comments' and therefore need to hook into this
 'pre_comment_on_post' and assign a dummy value to the comment content

 in wp 4.3.1 this could be easily done with:


 {{{
 if (isset($_POST['comment']) && $_POST['comment'] == "") {

                     $_POST['comment'] = "dummy content";
 }
 }}}

 but with the new function wp_handle_comment_submission() this doesn't work
 anymore as the superglobal $_POST[] is now mapped to $comment_data or
 better say $comment_content.

 these variables are also not in a global scope so my add_action function
 can't assign a value to $comment_content ;(

 i have explained my issue in detail here:

 http://wordpress.stackexchange.com/questions/215087/wp-4-4-1-allow-empty-
 comments-via-add-action-pre-comment-on-post

 how would i best solve this problem? if i have asked at the wrong place
 please foregive me, but i thought asking the wp core devs directly might
 be a good idea? if this is NOT then please let me know ;)

 also not sure if i should tag this question as 'bug' as all is working as
 expected. so i decided to got with 'feature request' ...

 thanks & greetings
 becki

 p.s. if someone asks why i want to allwo empty comments at all?? here's an
 answer i posted at another group:

 i use wordpress for a client as a documentation system. along with the
 standard comment users can submit other data, which gets added to the
 comment submit form via other add_action calls. so sometimes the users
 just wants to add those other custom values without actually posting a
 word in the comment field. therefore i want to allow empty comments by
 adding some dummy value which gets then again filtered out via an
 add_filter(comment_text) call.

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


More information about the wp-trac mailing list