Skip to content

Instantly share code, notes, and snippets.

@cameck
Last active March 29, 2016 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameck/63aebd2f10bfeb0f2c67 to your computer and use it in GitHub Desktop.
Save cameck/63aebd2f10bfeb0f2c67 to your computer and use it in GitHub Desktop.
Cancel Constant Contact Subscription if User does not Check the sign up box on more than one form.
<?php
function disable_newsletter_signup( $form_id ) {
global $ninja_forms_processing;
$form_id = $ninja_forms_processing->get_form_ID();
if ( $form_id == 1 || $form_id == 2 || $form_id == 3 ) {
switch ($form_id) {
case 1: //Form 1
$opt_in = $ninja_forms_processing->get_field_value( 32 );
break;
case 2: //Form 2
$opt_in = $ninja_forms_processing->get_field_value( 25 );
break;
case 3: //Form 3
$opt_in = $ninja_forms_processing->get_field_value( 14 );
break;
default:
break;
}
if ( $opt_in == 'unchecked' ) {
$ninja_forms_processing->update_form_setting( 'constant_contact_signup_form', false );
}
}
}
add_action( 'ninja_forms_pre_process', 'disable_newsletter_signup' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment