BP_REST_Topics_Actions_Endpoint::rest_update_spam( integer $topic_id, boolean $value )
Make topics as spam or not.
Description
Parameters
- $topic_id
-
(Required) Topic ID.
- $value
-
(Required) Action value.
Return
(bool|WP_Error)
Source
File: bp-forums/classes/class-bp-rest-topics-actions-endpoint.php
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 | protected function rest_update_spam( $topic_id , $value ) { // What is the user doing here? if ( ! current_user_can( 'moderate' , $topic_id ) ) { return new WP_Error( 'bp_rest_authorization_required' , __( 'You do not have permission to do this.' , 'buddyboss' ), array ( 'status' => 404, ) ); } $is_spam = bbp_is_topic_spam( $topic_id ); $status = true; if ( true === $is_spam && empty ( $value ) ) { $status = bbp_unspam_topic( $topic_id ); } elseif ( false === $is_spam && ! empty ( $value ) ) { $status = bbp_spam_topic( $topic_id ); } return $status ; } |
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.