WP_REST_Comments_Controller::check_edit_permission()
Checks if a comment can be edited or deleted.
Method of the class: WP_REST_Comments_Controller{}
No Hooks.
Return
true|false
. Whether the comment can be edited or deleted.
Usage
// protected - for code of main (parent) or child class $result = $this->check_edit_permission( $comment );
- $comment(WP_Comment) (required)
- Comment object.
Changelog
Since 4.7.0 | Introduced. |
WP_REST_Comments_Controller::check_edit_permission() WP REST Comments Controller::check edit permission code WP 6.6.1
protected function check_edit_permission( $comment ) { if ( 0 === (int) get_current_user_id() ) { return false; } if ( current_user_can( 'moderate_comments' ) ) { return true; } return current_user_can( 'edit_comment', $comment->comment_ID ); }