bp_document_move_document_to_folder( int $document_id, int $folder_id, int $group_id )
This function will document into the folder.
Description
Parameters
- $document_id
-
(Required)
- $folder_id
-
(Required)
- $group_id
-
(Required)
Return
(bool|int)
Source
File: bp-document/bp-document-functions.php
function bp_document_move_document_to_folder( $document_id = 0, $folder_id = 0, $group_id = 0 ) { global $wpdb, $bp; if ( 0 === $document_id ) { return false; } if ( (int) $document_id > 0 ) { $has_access = bp_document_user_can_edit( $document_id ); if ( ! $has_access ) { return false; } } if ( (int) $folder_id > 0 ) { $has_access = bp_folder_user_can_edit( $folder_id ); if ( ! $has_access ) { return false; } } if ( ! $group_id ) { $get_document = new BP_Document( $document_id ); if ( $get_document->group_id > 0 ) { $group_id = $get_document->group_id; } } $destination_privacy = 'loggedin'; if ( $group_id > 0 ) { $destination_privacy = 'grouponly'; } elseif ( $folder_id > 0 ) { $destination_folder = BP_Document_Folder::get_folder_data( array( $folder_id ) ); $destination_privacy = $destination_folder[0]->privacy; // Update modify date for destination folder. $destination_folder_update = new BP_Document_Folder( $folder_id ); $destination_folder_update->date_modified = bp_core_current_time(); $destination_folder_update->save(); } $document = new BP_Document( $document_id ); $document->folder_id = $folder_id; $document->group_id = $group_id; $document->date_modified = bp_core_current_time(); $document->save(); // Update document activity privacy. if ( ! $group_id ) { if ( ! empty( $document ) && ! empty( $document->attachment_id ) ) { $post_attachment = $document->attachment_id; $activity_id = get_post_meta( $post_attachment, 'bp_document_parent_activity_id', true ); if ( ! empty( $activity_id ) && bp_is_active( 'activity' ) ) { $activity = new BP_Activity_Activity( (int) $activity_id ); if ( bp_activity_user_can_delete( $activity ) ) { $activity->privacy = $destination_privacy; $activity->save(); } } } } return $document_id; }
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.