bbp_remove_user_forum_subscription( int $user_id, int $forum_id )
Remove a forum from user’s subscriptions
Description
Parameters
- $user_id
-
(Optional) User id
- $forum_id
-
(Optional) forum id
Return
(bool) True if the forum was removed from user's subscriptions, otherwise false
Source
File: bp-forums/users/functions.php
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 | function bbp_remove_user_forum_subscription( $user_id , $forum_id ) { if ( empty ( $user_id ) || empty ( $forum_id ) ) { return false; } $subscriptions = ( array ) bbp_get_user_subscribed_forum_ids( $user_id ); if ( empty ( $subscriptions ) ) { return false; } $pos = array_search ( $forum_id , $subscriptions ); if ( false === $pos ) { return false; } array_splice ( $subscriptions , $pos , 1 ); $subscriptions = array_filter ( $subscriptions ); if ( ! empty ( $subscriptions ) ) { $subscriptions = implode( ',' , wp_parse_id_list( $subscriptions ) ); update_user_option( $user_id , '_bbp_forum_subscriptions' , $subscriptions ); } else { delete_user_option( $user_id , '_bbp_forum_subscriptions' ); } wp_cache_delete( 'bbp_get_forum_subscribers_' . $forum_id , 'bbpress_users' ); do_action( 'bbp_remove_user_forum_subscription' , $user_id , $forum_id ); return true; } |
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.