bp_activity_create_parent_document_activity( $document_ids )
Create main activity for the media uploaded and saved.
Description
Parameters
- $document_ids
-
(Required)
Return
(mixed)
Source
File: bp-activity/bp-activity-filters.php
function bp_activity_create_parent_document_activity( $document_ids ) { global $bp_document_upload_count; if ( ! empty( $document_ids ) && ! isset( $_POST['bp_activity_update'] ) ) { $added_document_ids = $document_ids; $content = false; if ( ! empty( $_POST['content'] ) ) { /** * Filters the content provided in the activity input field. * * @param string $value Activity message being posted. * * @since BuddyPress 1.2.0 * */ $content = apply_filters( 'bp_activity_post_update_content', $_POST['content'] ); } $group_id = FILTER_INPUT( INPUT_POST, 'group_id', FILTER_SANITIZE_NUMBER_INT ); $folder_id = false; if ( bp_is_active( 'groups' ) && ! empty( $group_id ) && $group_id > 0 ) { $activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $group_id ) ); } else { $activity_id = bp_activity_post_update( array( 'content' => $content ) ); } //save document meta for activity. if ( ! empty( $activity_id ) ) { $privacy = 'public'; foreach ( (array) $added_document_ids as $document_id ) { $document = new BP_Document( $document_id ); // get one of the media's privacy for the activity privacy. $privacy = $document->privacy; // get document folder id. if ( ! empty( $document->folder_id ) ) { $folder_id = $document->folder_id; } if ( 1 === $bp_document_upload_count ) { //save media activity id in media $document->activity_id = $activity_id; $document->group_id = $group_id; $document->save(); } //save parent activity id in attachment meta. update_post_meta( $document->attachment_id, 'bp_document_parent_activity_id', $activity_id ); } bp_activity_update_meta( $activity_id, 'bp_document_ids', implode( ',', $added_document_ids ) ); // if document is from folder then save folder id in activity meta. if ( ! empty( $folder_id ) ) { bp_activity_update_meta( $activity_id, 'bp_document_folder_activity', $folder_id ); } if ( empty( $group_id ) ) { $main_activity = new BP_Activity_Activity( $activity_id ); if ( ! empty( $main_activity ) ) { $main_activity->privacy = $privacy; $main_activity->save(); } } } } return $document_ids; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.2.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.