AnsPress_Process_Form::edit_question()
Description #
Process edit question form.
Source #
File: includes/process-form.php
public function edit_question() { global $ap_errors, $validate; // Return if user do not have permission to edit this question. if ( ! ap_user_can_edit_question( $this->fields['edit_post_id'] ) ) { return; } $filter = apply_filters( 'ap_before_updating_question', false, $this->fields['description'] ); if ( true === $filter || is_array( $filter ) ) { if ( is_array( $filter ) ) { $this->result = $filter; } return; } $post = ap_get_post( $this->fields['edit_post_id'] ); $user_id = get_current_user_id(); $question_array = array( 'ID' => $post->ID, 'post_title' => $this->fields['title'], 'post_content' => $this->fields['description'], 'attach_uploads' => true, 'post_author' => $post->post_author, ); $question_array['post_status'] = ap_new_edit_post_status( $user_id, 'question', true ); if ( isset( $this->fields['is_private'] ) && $this->fields['is_private'] ) { $question_array['is_private'] = true; } // Check if anonymous post and have name. if ( ! is_user_logged_in() && ap_opt( 'allow_anonymous' ) && ! empty( $this->fields['anonymous_name'] ) ) { $question_array['anonymous_name'] = $this->fields['anonymous_name']; } $post_id = ap_save_question( $question_array ); if ( $post_id ) { ap_clear_unattached_media(); $this->redirect = get_permalink( $post_id ); // Trigger update hook. ap_trigger_qa_update_hook( $post_id, 'edited' ); ap_ajax_json( array( 'success' => true, 'action' => 'edited_question', 'redirect' => get_permalink( $post_id ), 'snackbar' => [ 'message' => __( 'Question updated successfully', 'anspress-question-answer' ), ], ) ); } }
Expand full source code Collapse full source code View on GitHub: includes/process-form.php:221
Add your comment