BBP_Replies_Admin::attributes_metabox_save( int $reply_id )
Pass the reply attributes for processing
Description
Parameters
- $reply_id
-
(Required) Reply id
Return
(int) Parent id
Source
File: bp-forums/admin/replies.php
public function attributes_metabox_save( $reply_id ) {
if ( $this->bail() ) return $reply_id;
// Bail if doing an autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $reply_id;
// Bail if not a post request
if ( ! bbp_is_post_request() )
return $reply_id;
// Check action exists
if ( empty( $_POST['action'] ) )
return $reply_id;
// Nonce check
if ( empty( $_POST['bbp_reply_metabox'] ) || !wp_verify_nonce( $_POST['bbp_reply_metabox'], 'bbp_reply_metabox_save' ) )
return $reply_id;
// Current user cannot edit this reply
if ( !current_user_can( 'edit_reply', $reply_id ) )
return $reply_id;
// Get the reply meta post values
$topic_id = !empty( $_POST['parent_id'] ) ? (int) $_POST['parent_id'] : 0;
$forum_id = !empty( $_POST['bbp_forum_id'] ) ? (int) $_POST['bbp_forum_id'] : bbp_get_topic_forum_id( $topic_id );
$reply_to = !empty( $_POST['bbp_reply_to'] ) ? (int) $_POST['bbp_reply_to'] : 0;
// Get reply author data
$anonymous_data = bbp_filter_anonymous_post_data();
$author_id = bbp_get_reply_author_id( $reply_id );
$is_edit = (bool) isset( $_POST['save'] );
// Formally update the reply
bbp_update_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $author_id, $is_edit, $reply_to );
// Allow other fun things to happen
do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $topic_id, $forum_id, $reply_to );
do_action( 'bbp_author_metabox_save', $reply_id, $anonymous_data );
return $reply_id;
}
Changelog
| Version | Description |
|---|---|
| bbPress (r2746) | 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.