lundi 5 juillet 2021

WordPress - Add Yes/No to custom field if checkbox is checked

I've created a custom field (type read only) with ACF Field for users (Label: "Check Field Privacy"; name "privacy_field").

In my website I add a form where there is a checkbox to confirm the reading of the website policy. This is the checkbox

<p>
<input type="checkbox" name="foo_privacy_policy" id="foo_privacy_policy" class="checkbox" />
<label for="foo_privacy_policy"><?php _e( 'I accept terms and.......', 'foo' ) ?>
</label>

I need to assign "Yes" to Check Privacy Field if the checkbox is checked and "No" if checkbox isn't checked

I try with:

if ( isset($_POST['foo_privacy_policy']) ) {
    $privacy_field = "YES"; 
            }

It doesn't work...




Aucun commentaire:

Enregistrer un commentaire