BP_REST_Topics_Endpoint::prepare_topic_for_database( WP_REST_Request $request )
Prepare a single topic for create or update
Description
Parameters
- $request
-
(Required) Request object.
Return
(object) $topic User object.
Source
File: bp-forums/classes/class-bp-rest-topics-endpoint.php
protected function prepare_topic_for_database( $request ) { $topic = new stdClass(); if ( isset( $request['id'] ) ) { $topic->bbp_topic_id = $request['id']; } if ( isset( $request['parent'] ) ) { $topic->bbp_forum_id = $request['parent']; } if ( isset( $request['group'] ) ) { $topic->bbp_group_id = $request['group']; } if ( isset( $request['title'] ) ) { $topic->bbp_topic_title = $request['title']; } if ( isset( $request['status'] ) ) { $topic->bbp_topic_status = $request['status']; } if ( isset( $request['topic_tags'] ) ) { $topic->bbp_topic_tags = $request['topic_tags']; } if ( isset( $request['content'] ) ) { $topic->bbp_topic_content = $request['content']; } if ( isset( $request['sticky'] ) ) { $topic->bbp_stick_topic = $request['sticky']; } if ( isset( $request['reason_editing'] ) ) { $topic->bbp_topic_edit_reason = $request['reason_editing']; } if ( isset( $request['log'] ) ) { $topic->bbp_log_topic_edit = $request['log']; } if ( isset( $request['subscribe'] ) && ( true === $request['subscribe'] ) ) { $topic->bbp_topic_subscription = true; } elseif ( isset( $request['subscribe'] ) && ( false === $request['subscribe'] ) ) { $topic->bbp_topic_subscription = false; } /** * Filter topic data before inserting user via REST API * * @param object $topic Topic object. * @param WP_REST_Request $request Request object. */ return apply_filters( 'bp_rest_topic_object', $topic, $request ); }
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.