bbp_remove_topic_from_all_favorites( int $topic_id )

Remove a deleted topic from all users’ favorites

Description

Parameters

$topic_id

(Required) Get the topic id to remove

Source

File: bp-forums/topics/functions.php

2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
function bbp_remove_topic_from_all_favorites( $topic_id = 0 ) {
    $topic_id = bbp_get_topic_id( $topic_id );
 
    // Bail if no topic
    if ( empty( $topic_id ) )
        return;
 
    // Get users
    $users = (array) bbp_get_topic_favoriters( $topic_id );
 
    // Users exist
    if ( !empty( $users ) ) {
 
        // Loop through users
        foreach ( $users as $user ) {
 
            // Remove each user
            bbp_remove_user_favorite( $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.