ap_user_can_delete_attachment( integer $attacment_id, boolean|integer $user_id = false )
Description #
Check if user can delete an attachment.
Parameters #
- $attacment_idinteger (Required) Attachment ID.
- $user_idboolean | integer (Optional) User ID. Default value: false
Source #
File: includes/class/roles-cap.php
function ap_user_can_delete_attachment( $attacment_id, $user_id = false ) {
if ( false === $user_id ) {
$user_id = get_current_user_id();
}
if ( is_super_admin( $user_id ) ) {
return true;
}
$attachment = ap_get_post( $attacment_id );
if ( ! $attachment ) {
return false;
}
// Check if attachment post author matches `$user_id`.
if ( $user_id == $attachment->post_author ) { // 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:1064
Add your comment