bp_media_update_activity_privacy( int $activity_id, string $privacy = '' )

Update activity media privacy based on activity.

Description

Parameters

$activity_id

(Required) Activity ID.

$privacy

(Optional) Privacy

Default value: ''

Source

File: bp-media/bp-media-functions.php

2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
function bp_media_update_activity_privacy( $activity_id = 0, $privacy = '' ) {
    global $wpdb, $bp;
 
    if ( empty( $activity_id ) || empty( $privacy ) ) {
        return;
    }
 
    // Update privacy for the media which are uploaded in activity.
    $media_ids = bp_activity_get_meta( $activity_id, 'bp_media_ids', true );
    if ( ! empty( $media_ids ) ) {
        $media_ids = explode( ',', $media_ids );
        if ( ! empty( $media_ids ) ) {
            foreach ( $media_ids as $id ) {
                $media = new BP_Media( $id );
                if ( ! empty( $media->id ) ) {
                    $media->privacy = $privacy;
                    $media->save();
                }
            }
        }
    }
}

Changelog

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.