Skip to content

Instantly share code, notes, and snippets.

@jarrodagims
Created March 5, 2019 21:26
Show Gist options
  • Save jarrodagims/0518b375b065184aefd66f1b7b95c678 to your computer and use it in GitHub Desktop.
Save jarrodagims/0518b375b065184aefd66f1b7b95c678 to your computer and use it in GitHub Desktop.
PHP switch
//redirect to thank you page
function mycustom_wp_footer()
{
echo '<script type="text/javascript">';
echo 'var formTitle;';
echo 'switch(event.detail.contactFormId) {';
echo 'case "14567": formTitle = "Contact Form"; formThank: "thank-you"';
echo 'break;';
echo 'case "14683": formTitle = "Service Requests"; formThank: "thank-you-service"';
echo 'break;';
echo 'default: formTitle = "Contact Form"; formThank: "thank-you"';
echo '}';
echo 'dataLayer.push({"event": formTitle + " " + "Form Submitted", "cf7.formID": event.detail.contactFormId});';
echo 'location = "' . SITEURL . '/' + formThank + '/";';
echo '}, false );';
echo '</script>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment