ap_user_can_delete_comment( integer $comment_id, integer|false $user_id = false )

Description #

Check if user can delete comment.

Parameters #

  • $comment_id
    integer (Required) Comment_ID.
  • $user_id
    integer | false (Optional) User ID. Default value: false

Source #

File: includes/class/roles-cap.php

function ap_user_can_delete_comment( $comment_id, $user_id = false ) {
	if ( false === $user_id ) {
		$user_id = get_current_user_id();
	}

	if ( is_super_admin( $user_id ) || user_can( $user_id, 'ap_delete_others_comment' ) ) {
		return true;
	}

	if ( user_can( $user_id, 'ap_delete_comment' ) && get_comment( $comment_id )->user_id == $user_id ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
		return true;
	}

	return false;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment