BP_REST_Reply_Endpoint::prepare_reply_for_database( WP_REST_Request $request )
Prepare a single reply for create or update
Description
Parameters
- $request
-
(Required) Request object.
Return
(object) $reply User object.
Source
File: bp-forums/classes/class-bp-rest-reply-endpoint.php
protected function prepare_reply_for_database( $request ) { $reply = new stdClass(); if ( isset( $request['id'] ) ) { $reply->bbp_reply_id = $request['id']; } elseif ( isset( $request['reply_id'] ) ) { $reply->bbp_reply_id = $request['reply_id']; } if ( isset( $request['topic_id'] ) ) { $reply->bbp_topic_id = $request['topic_id']; } if ( isset( $request['forum_id'] ) ) { $reply->bbp_forum_id = $request['forum_id']; } if ( isset( $request['title'] ) ) { $reply->bbp_reply_title = $request['title']; } if ( isset( $request['content'] ) ) { $reply->bbp_reply_content = $request['content']; } if ( isset( $request['reply_to'] ) ) { $reply->bbp_reply_to = $request['reply_to']; } if ( isset( $request['tags'] ) ) { $reply->bbp_topic_tags = $request['tags']; } if ( isset( $request['reason'] ) ) { $reply->bbp_reply_edit_reason = $request['reason']; } if ( isset( $request['subscribe'] ) && ( true === $request['subscribe'] ) ) { $reply->bbp_topic_subscription = true; } elseif ( isset( $request['subscribe'] ) && ( false === $request['subscribe'] ) ) { $reply->bbp_topic_subscription = false; } if ( isset( $reply->bbp_topic_subscription ) ) { $_POST['bbp_topic_subscription'] = ( $reply->bbp_topic_subscription ) ? 'bbp_subscribe' : ''; } if ( isset( $request['log'] ) ) { $reply->bbp_log_reply_edit = $request['log']; } /** * Filter reply data before inserting user via REST API * * @param object $reply Reply object. * @param WP_REST_Request $request Request object. */ return apply_filters( 'bp_rest_reply_object', $reply, $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.