LLMS_Reviews::process_review()

This function adds the review to the database. It is called by the AJAX handler when the submit review button is pressed. This function gathers the data from $_POST and then adds the review with the appropriate content.


Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.review.php

	public function process_review() {
		// Check the nonce.
		if ( ! isset( $_POST['llms_review_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['llms_review_nonce'] ), 'llms-review' ) ) {
			return;
		}

		$parent_id = llms_filter_input_sanitize_string( INPUT_POST, 'pageID' );

		// Make sure the current user can write reviews yet.
		if ( ! self::current_user_can_write_review( $parent_id ) ) {
			return;
		}

		$post = array(
			'post_content' => llms_filter_input_sanitize_string( INPUT_POST, 'review_text' ), // The full text of the post.
			'post_name'    => llms_filter_input_sanitize_string( INPUT_POST, 'review_title' ), // The name (slug) for your post.
			'post_title'   => llms_filter_input_sanitize_string( INPUT_POST, 'review_title' ), // The title of your post.
			'post_status'  => 'publish',
			'post_type'    => 'llms_review',
			'post_parent'  => $parent_id, // Sets the parent of the new post, if any. Default 0.
			'post_excerpt' => llms_filter_input_sanitize_string( INPUT_POST, 'review_title' ),
		);

		$result = wp_insert_post( $post, true );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.5.2 Now checking if the user can write a review.
5.9.0 Stop using deprecated FILTER_SANITIZE_STRING.
1.2.7 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.