WP_REST_Comments_Controller::check_edit_permission()protectedWP 4.7.0

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() code WP 6.5.2

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 );
}