bbp_remove_topic_from_all_subscriptions( int $topic_id )

Remove a deleted topic from all users’ subscriptions

Description

Parameters

$topic_id

(Required) Get the topic id to remove

Source

File: bp-forums/topics/functions.php

2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
function bbp_remove_topic_from_all_subscriptions( $topic_id = 0 ) {
 
    // Subscriptions are not active
    if ( !bbp_is_subscriptions_active() )
        return;
 
    $topic_id = bbp_get_topic_id( $topic_id );
 
    // Bail if no topic
    if ( empty( $topic_id ) )
        return;
 
    // Get users
    $users = (array) bbp_get_topic_subscribers( $topic_id );
 
    // Users exist
    if ( !empty( $users ) ) {
 
        // Loop through users
        foreach ( $users as $user ) {
 
            // Remove each user
            bbp_remove_user_subscription( $user, $topic_id );
        }
    }
}

Changelog

Changelog
Version Description
bbPress (r2652) 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.