Last active
March 24, 2025 05:28
-
-
Save wpmudev-sls/f94133c55a61733fd3057da2c396da0a to your computer and use it in GitHub Desktop.
[Forminator Pro] - Consent field not allowing submission with draft form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Forminator Pro] Fix draft form submission with consent field | |
* Description: Fixes draft form submission with consent field. | |
* Author: Prashant @ WPMUDEV | |
* Task: SLS-6945 | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
add_filter( | |
'forminator_field_consent_markup', | |
function ( $html, $id ) { | |
$draft_id = isset( $_REQUEST['draft'] ) ? Forminator_Core::sanitize_text_field( 'draft' ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
if ( empty( $draft_id ) ) { | |
return $html; | |
} | |
$draft = new Forminator_Form_Entry_Model( $draft_id ); | |
if ( is_null( $draft->form_id ) ) { | |
return $html; | |
} | |
$html = str_replace( 'id="' . $id . '"', 'id="' . $id . '" checked', $html ); | |
return $html; | |
}, | |
10, | |
2 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment