Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save spivurno/5cc99da16d877ba32616a368d1a60c88 to your computer and use it in GitHub Desktop.
Save spivurno/5cc99da16d877ba32616a368d1a60c88 to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Get Form ID by Form Name
<?php
/**
* Gravity Wiz // Gravity Forms // Get Form ID by Form Name
*
* @param $name string The name of the form.
*
* @return int The form ID.
*/
function gw_get_form_id_by_name( $name ) {
global $wpdb;
$form_id = $wpdb->get_var( $wpdb->prepare( 'select id from wp_rg_form where title = \'%s\'', $name ) );
return (int) $form_id;
}
@Jadine-ibay
Copy link

please help? I can't get this to work.

@sbassah
Copy link

sbassah commented Jan 21, 2022

@Jadine-ibay This code snippet is outdated. Gravity Forms now has a function for this functionality. Below is a link to the updated version of the code snippet that makes use of this function.

https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-get-form-id-by-form_title.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment