Skip to content

Instantly share code, notes, and snippets.

@certainlyakey
Created March 19, 2018 08:16
Show Gist options
  • Save certainlyakey/5b2d71160c57ad38de45b6eefdfd9b50 to your computer and use it in GitHub Desktop.
Save certainlyakey/5b2d71160c57ad38de45b6eefdfd9b50 to your computer and use it in GitHub Desktop.
Gravity Forms + Wordpress — retrieve a Gravity form by its class (set in each form settings)
<?php
// Retrieve a Gravity form by class (set in each form settings) 'js-overlay-form'
if ( class_exists( 'GFAPI' ) ) {
$forms = GFAPI::get_forms();
$class_key = 'cssClass';
$contactform_class = 'js-overlay-form';
foreach ($forms as $form) {
if (array_key_exists($class_key, $form) && $form[$class_key] == $contactform_class) {
$contactform_id = $form['id'];
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment