Created
March 19, 2018 08:16
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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