Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Attach media with comments on a mediapress activity.
*
* @param int $comment_id comment id.
* @param array $r args.
* @param BP_Activity_Activity $activity activity object.
*/
function mpp_custom_comment_posted( $comment_id, $r, $activity ) {
$comment = new BP_Activity_Activity( $comment_id );
$parent_id = $comment->item_id;
$parent = new BP_Activity_Activity( $parent_id );
if ( 'mpp_media_upload' !== $parent->type ) {
return;
}
$attached_ids = mpp_activity_get_attached_media_ids( $comment->item_id );
if ( ! $attached_ids || count( $attached_ids ) > 1 ) {
return;
}
$media_id = current( $attached_ids );
mpp_activity_update_media_id( $comment_id, $media_id );
}
add_action( 'bp_activity_comment_posted', 'mpp_custom_comment_posted', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.