BP_REST_Topics_Endpoint::get_topic_action_states( int $topic_id )
Get topic actions state based on current user.
Description
Parameters
- $topic_id
-
(Required) ID of the topic.
Return
(array|void)
Source
File: bp-forums/classes/class-bp-rest-topics-endpoint.php
2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 | public function get_topic_action_states( $topic_id ) { if ( empty ( $topic_id ) ) { return ; } $topic_id = (int) $topic_id ; $user_id = bbp_get_user_id( 0, true, true ); $state = array ( 'subscribed' => '' , 'favorited' => '' , 'open' => bbp_is_topic_open( $topic_id ), 'sticky' => bbp_is_topic_sticky( $topic_id ), 'super_sticky' => bbp_is_topic_super_sticky( $topic_id ), 'spam' => bbp_is_topic_spam( $topic_id ), 'trash' => bbp_is_topic_trash( $topic_id ), ); if ( bbp_is_favorites_active() && current_user_can( 'edit_user' , $user_id ) ) { $state [ 'favorited' ] = bbp_is_user_favorite( $user_id , $topic_id ); } if ( bbp_is_subscriptions_active() && current_user_can( 'edit_user' , $user_id ) ) { $state [ 'subscribed' ] = bbp_is_user_subscribed( $user_id , $topic_id ); } return $state ; } |
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.