bbp_get_user_favorites( int $user_id )

Get a user’s favorite topics

Description

Parameters

$user_id

(Optional) User id

Return

(array|bool) Results if user has favorites, otherwise false

Source

File: bp-forums/users/functions.php

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
function bbp_get_user_favorites( $user_id = 0 ) {
    $user_id = bbp_get_user_id( $user_id );
    if ( empty( $user_id ) )
        return false;
 
    // If user has favorites, load them
    $favorites = bbp_get_user_favorites_topic_ids( $user_id );
    if ( !empty( $favorites ) ) {
        $query = bbp_has_topics( array( 'post__in' => $favorites ) );
    } else {
        $query = false;
    }
 
    return apply_filters( 'bbp_get_user_favorites', $query, $user_id, $favorites );
}

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.