ap_user_can_edit_comment( integer $comment_id, integer|false $user_id = false )
Description #
Check if user can edit comment.
Parameters #
- $comment_idinteger (Required) Comment ID.
- $user_idinteger | false (Optional) User ID. Default value: false
Source #
File: includes/class/roles-cap.php
function ap_user_can_edit_comment( $comment_id, $user_id = false ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } if ( is_super_admin() || current_user_can( 'ap_edit_others_comment' ) ) { return true; } $comment = get_comment( $comment_id ); /** * Filter to hijack ap_user_can_edit_comment. * * @param boolean|string $apply_filter Apply current filter, empty string by default. * @param integer|object $post_id Post ID or object. * @param integer $user_id User ID. * @return boolean * @since 2.4.6 */ $filter = apply_filters( 'ap_user_can_edit_comment', '', $comment_id, $user_id ); if ( true === $filter ) { return true; } elseif ( false === $filter ) { return false; } // Do not allow to edit if not approved. if ( '0' == $comment->comment_approved ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual return false; } // Don't allow user to comment if they don't have permission to read post. if ( ! ap_user_can_read_post( $comment->comment_post_ID, $user_id ) ) { return false; } if ( user_can( $user_id, 'ap_edit_comment' ) && $user_id == $comment->user_id ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual return true; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/class/roles-cap.php:551
Add your comment