wphooks.info - rest_after_insert_comment

rest_after_insert_comment

(trunk - 5.1-alpha-44286)

*** New in trunk ***

The hook occurs in the following 2 files

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
		/**
		 * Fires completely after a comment is created or updated via the REST API.
		 *
		 * @since 5.0.0
		 *
		 * @param WP_Comment      $comment  Inserted or updated comment object.
		 * @param WP_REST_Request $request  Request object.
		 * @param bool            $creating True when creating a comment, false
		 *                                  when updating.
		 */
		do_action( 'rest_after_insert_comment', $comment, $request, true );

		$response = $this->prepare_item_for_response( $comment, $request );
		$response = rest_ensure_response( $response );

		$response->set_status( 201 );
		$response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment_id ) ) );

		return $response;
	}
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
		$fields_update = $this->update_additional_fields_for_object( $comment, $request );

		if ( is_wp_error( $fields_update ) ) {
			return $fields_update;
		}

		$request->set_param( 'context', 'edit' );

		/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
		do_action( 'rest_after_insert_comment', $comment, $request, false );

		$response = $this->prepare_item_for_response( $comment, $request );

		return rest_ensure_response( $response );
	}

	/**
	 * Checks if a given request has access to delete a comment.
	 *