WP_REST_Comments_Controller::check_edit_permission() WordPress Method

The WP_REST_Comments_Controller::check_edit_permission() method is used to check if the current user has the ability to edit a given comment. This is determined by the user's capability to edit_posts . If the user does not have this capability, false is returned.

WP_REST_Comments_Controller::check_edit_permission( WP_Comment $comment ) #

Checks if a comment can be edited or deleted.


Parameters

$comment

(WP_Comment)(Required)Comment object.


Top ↑

Return

(bool) Whether the comment can be edited or deleted.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

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


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.