Snippets

These snippets can be placed in your theme's functions.php file or a code snippets plugin.


Default: I agree to receive marketing offers and updates from ( Business Name )

function custom_marketing_consent_label( $label, $field ) {
	// Check if the field is marketing consent
	if ( $field == 'marketing_consent' ) {
		// Modify the label to include a hyperlink
		$label = sprintf( _x( 'Email me a weekly newsletter, exclusive products and promo deals. You can unsubscribe at anytime.', 'field_label', 'groundhogg' ), $url, get_bloginfo() );
	}

	// Return the modified label
	return $label;
}
// Hook the custom function into the groundhogg/default_field_label filter
add_filter( 'groundhogg/default_field_label', 'custom_marketing_consent_label', 10, 2 );
Modify Terms Agreement

Default: I agree to terms and conditions of ( Business Name )

function custom_terms_and_conditions_label( $label, $field ) {
	// Check if the field is the terms and conditions
	if ( $field == 'terms_agreement' ) {
		// Change the URL to where your terms exist
		$url = 'https://example.com/terms/';
		// Modify the label to include a hyperlink
		$label = sprintf( _x( 'I agree to <a href="%s" target="_blank">terms and conditions</a> of %s.', 'field_label', 'groundhogg' ), $url, get_bloginfo() );
	}

	// Return the modified label
	return $label;
}

// Hook the custom function into the groundhogg/default_field_label filter
add_filter( 'groundhogg/default_field_label', 'custom_terms_and_conditions_label', 10, 2 );

Default: I agree to ( Business Name )'s storage and processing of my personal data.

function custom_gdpr_consent_label( $label, $field ) {
	// Check if the field is marketing consent
	if ( $field == 'gdpr_consent' ) {
		// Modify the label to include a hyperlink
		$label = sprintf( _x( '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.', 'field_label', 'groundhogg' ), $url, get_bloginfo() );
	}

	// Return the modified label
	return $label;
}
// Hook the custom function into the groundhogg/default_field_label filter
add_filter( 'groundhogg/default_field_label', 'custom_gdprg_consent_label', 10, 2 );
Modify Confirmation Text

Default: Confirm your email.

function custom_confirmation_text($default_text) {
    // Modify the text as needed
    $custom_text = 'Your custom confirmation text goes here.';
    
    return $custom_text;
}
// Hook into the groundhogg/replacements/confirmation_text filter
add_filter('groundhogg/replacements/confirmation_text', 'custom_confirmation_text');

Default: Privacy Policy

add_filter( 'gettext', 'gh_change_privacy_policy' );
/**
  * Change "Privacy Policy" in footer
  *
  * @param $text string 
  * @return $text string
  * * * * * * * * * * * * * * * * * * */
function gh_change_privacy_policy( $text ) {

    $text = str_ireplace( "Privacy Policy", "Privacy Disclosure",  $text );

    return $text;
}

Default: Terms

add_filter( 'gettext', 'gh_change_terms' );
/**
  * Change "Terms" in footer
  *
  * @param $text string 
  * @return $text string
  * * * * * * * * * * * * * * * * * * */
function gh_change_terms( $text ) {

    $text = str_ireplace( "Terms", "Terms & Conditions",  $text );

    return $text;
}

Default: Unsubscribe

add_filter( 'gettext', 'gh_change_unsubscribe' );
/**
  * Change "Unsubscribe" in footer
  *
  * @param $text string 
  * @return $text string
  * * * * * * * * * * * * * * * * * * */
function gh_change_unsubscribe( $text ) {

    $text = str_ireplace( "Unsubscribe", "Custom link text",  $text );

    return $text;
}

Default: Unsubscribe

add_filter( 'gettext', 'gh_change_dont_want_these_emails' );
/**
  * Change "Don't want these emails?" in footer
  *
  * @param $text string 
  * @return $text string
  * * * * * * * * * * * * * * * * * * */
function gh_change_dont_want_these_emails( $text ) {

    $text = str_ireplace( "Don't want these emails?", "Custom Message",  $text );

    return $text;
}
Modify "View this email in your browser."
// Change the "View this email in your browser." text
add_filter( 'groundhogg/email_template/browser_view_text', 'Custom Message', 11 );
Hide Groundhogg Admin Widget
// Add custom CSS to WordPress dashboard
function remove_gh_admin_widget() {
    echo '<style>
		li#wp-admin-bar-groundhogg {
    		display: none;
		}
	</style>';
}
add_action('admin_head', 'remove_gh_admin_widget');
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us