WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 7 months ago

#39274 new feature request

Consider a capability for posting comments

Reported by: johnjamesjacoby Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Comments Keywords: 2nd-opinion
Focuses: Cc:
PR Number:

Description

The wp_handle_comment_submission() function currently includes a bunch of internal logic for concluding if a comment submission is possible given a number of criteria relative to:

  • The post the comment would belong to
  • Settings for the post
  • Site settings
  • Current user if logged in
  • Email address validation if logged out

While some of this logic is relatively complex, all of it together answers the question: can the current user (logged in or out) comment on the current post. As such, I think it would make sense to consider a dedicated mapped meta capability to identifying whether the current user has the ability to post a comment.

There may be some/many things that prevent this from being easily achievable, and I haven't dug too deeply into investigating what they might be exactly.

Change History (1)

#1 @johnbillion
3 years ago

The fundamental problem here is that current_user_can() should always return false for a non-logged-in user, although some plugins such as BuddyPress check the exist capability against non-logged-in users.

The logic in wp_handle_comment_submission() could be further abstracted into a separate function, but it doesn't make sense for it to be mapped to a capability.

Note: See TracTickets for help on using tickets.