Change the data processing consent checkbox text

📅 Published on

📝 Last updated

Documentation

»

Code Samples

»

Change the data processing consent checkbox text

Changes the text in Groundhogg forms for the data processing consent (GDPR) checkbox field

<?php

/**
 * Modify the GDPR consent field label.
 *
 * This function customizes the label for the "gdpr_consent" checkbox field,
 * ensuring clarity and compliance with cookie policies.
 *
 * @param string $label The default field label.
 * @param string $field The field type.
 * @return string The modified GDPR consent field label.
 */
function custom_gdpr_consent_label( $label, $field ) {
    // Check if the field is GDPR consent
    if ( $field === 'gdpr_consent' ) {
        $label = __( 
            'This website uses cookies to enhance your browsing experience. By checking the box, you consent to the use of all essential and non-essential cookies.', 
            'groundhogg' 
        );
    }

    return $label;
}

// Hook the custom function into the Groundhogg default field label filter.
add_filter( 'groundhogg/default_field_label', 'custom_gdpr_consent_label', 10, 2 );

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.