bbp_is_user_subscribed( int $user_id, $object_id )
Check if a topic or forum is in user’s subscription list or not
Description
Parameters
- $user_id
-
(Optional) User id
- $forum_id
-
(Optional) Topic id
Return
(bool) True if the forum or topic is in user's subscriptions, otherwise false
Source
File: bp-forums/users/functions.php
function bbp_is_user_subscribed( $user_id = 0, $object_id = 0 ) { // Assume user is not subscribed $retval = false; // Setup ID's array $subscribed_ids = array(); // User and object ID's are passed if ( ! empty( $user_id ) && ! empty( $object_id ) ) { // Get the post type $post_type = get_post_type( $object_id ); // Post exists, so check the types if ( ! empty( $post_type ) ) { switch( $post_type ) { // Forum case bbp_get_forum_post_type() : $subscribed_ids = bbp_get_user_subscribed_forum_ids( $user_id ); $retval = bbp_is_user_subscribed_to_forum( $user_id, $object_id, $subscribed_ids ); break; // Topic (default) case bbp_get_topic_post_type() : default : $subscribed_ids = bbp_get_user_subscribed_topic_ids( $user_id ); $retval = bbp_is_user_subscribed_to_topic( $user_id, $object_id, $subscribed_ids ); break; } } } return (bool) apply_filters( 'bbp_is_user_subscribed', $retval, $user_id, $object_id, $subscribed_ids ); }
Changelog
Version | Description |
---|---|
bbPress (r5156) | 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.