acf_form_front::check_submit_formpublicACF 5.5.10

This function will maybe submit form data

Method of the class: acf_form_front{}

No Hooks.

Returns

null. Nothing (null).

Usage

$acf_form_front = new acf_form_front();
$acf_form_front->check_submit_form();

Changelog

Since 5.5.10 Introduced.

acf_form_front::check_submit_form() code ACF 6.8.8

function check_submit_form() {

	// Verify nonce.
	if ( ! acf_verify_nonce( 'acf_form' ) ) {
		return false;
	}

	// Confirm form was submit.
	if ( ! isset( $_POST['_acf_form'] ) ) {
		return false;
	}

	// Load registered form using id.
	$form = $this->get_form( acf_sanitize_request_args( $_POST['_acf_form'] ) );

	// Fallback to encrypted JSON.
	if ( ! $form ) {
		$form = json_decode( acf_decrypt( sanitize_text_field( $_POST['_acf_form'] ) ), true );
		if ( ! $form ) {
			return false;
		}
	}

	$form = $this->merge_form_meta( $form );

	// Run kses on all $_POST data.
	if ( $form['kses'] && isset( $_POST['acf'] ) ) {
		$_POST['acf'] = wp_kses_post_deep( $_POST['acf'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- False positive.
	}

	// Validate data and show errors.
	// Todo: Return WP_Error and show above form, keeping input values.
	acf_validate_save_post( true );

	// Submit form.
	$this->submit_form( $form );
}