Title: WP_REST_Comments_Controller::check_edit_permission
Published: December 6, 2016
Last modified: May 20, 2026

---

# WP_REST_Comments_Controller::check_edit_permission( WP_Comment $comment ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#wp--skip-link--target)

Checks if a comment can be edited or deleted.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#parameters)󠁿

 `$comment`[WP_Comment](https://developer.wordpress.org/reference/classes/wp_comment/)
required

Comment object.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#return)󠁿

 bool Whether the comment can be edited or deleted.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L1954)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php#L1954-L1964)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#related)󠁿

| Uses | Description | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [get_current_user_id()](https://developer.wordpress.org/reference/functions/get_current_user_id/)`wp-includes/user.php` |

Gets the current user’s ID.

  |

| Used by | Description | 
| [WP_REST_Comments_Controller::update_item_permissions_check()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/update_item_permissions_check/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Checks if a given REST request has access to update a comment.

  | 
| [WP_REST_Comments_Controller::delete_item_permissions_check()](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/delete_item_permissions_check/)`wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php` |

Checks if a given request has access to delete a comment.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_comments_controller/check_edit_permission/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rest_comments_controller%2Fcheck_edit_permission%2F)
before being able to contribute a note or feedback.