WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#35541 closed feature request (worksforme)

$_POST['comment'] / $comment_content on add_action 'pre_comment_on_post'

Reported by: becki Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Comments Keywords:
Focuses: Cc:

Description

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.

Change History (3)

#1 @becki
6 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

hello again,

i made a bit of more thinking about this yesterday and decided for a different approach to get things working again with wordpress version 4.4.1

instead of fixing things afterwards in worpdress i decided to prepare thing properly with jQuery during form submit.

if someone is interessted, here are the details:

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

sorry for bothering trac with my question ;(
i promise it won't happen again ;)

greetings
becki

#2 @johnbillion
6 years ago

  • Milestone Awaiting Review deleted
  • Version changed from 4.4.1 to 4.4

Thanks for the followup @becki.

#3 @Guss77
3 years ago

I'm encountering the same problem, when upgrading from pre-4.4 to a new version. For me it is not really possible to preload the content during submission.

Can pre_comment_on_post be fixed, please, so it can be used to modify comment content - like it was before Wordpress 4.4?

If this is something that can be discussed, but not on a closed ticket - please let me know so I can open a new ticket.

Last edited 3 years ago by Guss77 (previous) (diff)
Note: See TracTickets for help on using tickets.