bp_folder_user_can_delete( int|BP_Document_Folder $folder = false )
Determine if the current user can delete an folder item.
Description
Parameters
- $folder
-
(Optional) BP_Document_Folder object or ID of the folder.
Default value: false
Return
(bool) True if can delete, false otherwise.
Source
File: bp-document/bp-document-template.php
function bp_folder_user_can_delete( $folder = false ) { // Assume the user cannot delete the folder item. $can_delete = false; if ( empty( $folder ) ) { return $can_delete; } if ( ! is_object( $folder ) ) { $folder = new BP_Document_Folder( $folder ); } if ( empty( $folder ) ) { return $can_delete; } // Only logged in users can delete folder. if ( is_user_logged_in() ) { // Groups documents have their own access. if ( ! empty( $folder->group_id ) && groups_can_user_manage_document( bp_loggedin_user_id(), $folder->group_id ) ) { $can_delete = true; // Users are allowed to delete their own folder. } elseif ( isset( $folder->user_id ) && bp_loggedin_user_id() === $folder->user_id ) { $can_delete = true; } // Community moderators can always delete folder (at least for now). if ( bp_current_user_can( 'bp_moderate' ) ) { $can_delete = true; } } /** * Filters whether the current user can delete an folder item. * * @since BuddyBoss 1.4.0 * * @param bool $can_delete Whether the user can delete the item. * @param object $folder Current folder item object. */ return (bool) apply_filters( 'bp_folder_user_can_delete', $can_delete, $folder ); }
Changelog
Version | Description |
---|---|
BuddyBoss 1.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.