BP_REST_Topics_Actions_Endpoint::action_items( WP_REST_Request $request )

Actions on Topic

Description

Parameters

$request

(Required) Full details about the request.

Return

(WP_REST_Response) | WP_Error

Source

File: bp-forums/classes/class-bp-rest-topics-actions-endpoint.php

998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
public function action_items( $request ) {
 
    $action   = $request->get_param( 'action' );
    $value    = $request->get_param( 'value' );
    $topic_id = $request->get_param( 'id' );
    $user_id  = bbp_get_user_id( 0, true, true );
    $retval   = '';
 
    switch ( $action ) {
        case 'favorite':
            $retval = $this->rest_update_favorite( $topic_id, $value, $user_id );
            break;
        case 'subscribe':
            $retval = $this->rest_update_subscribe( $topic_id, $value, $user_id );
            break;
        case 'close':
            $retval = $this->rest_update_close( $topic_id, $value );
            break;
        case 'sticky':
        case 'super_sticky':
            $retval = $this->rest_update_sticky( $topic_id, $action, $value );
            break;
        case 'spam':
            $retval = $this->rest_update_spam( $topic_id, $value );
            break;
        case 'trash':
            $retval = $this->rest_update_trash( $topic_id, $value );
            break;
    }
 
    if ( is_wp_error( $retval ) ) {
        return $retval;
    }
 
    return $this->get_item(
        array(
            'id'      => $topic_id,
            'context' => 'view',
        )
    );
}

Changelog

Changelog
Version Description
0.1.0 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.