Using form name instead of for ids in hooks [RESOLVED]

We have a multi site configuration using gravity forms, and use several gravity forms hooks for pre-rendering , confirmations and notifications.
In order to make management easier, we are looking at using form names instead of form ids on the hooks and came across this snippet of code.

My question is, does gravity forms see this as a valid thing to do, or is there something we should be aware of.

We would also, if possible , like to use the form name when using a shortcode. Is this possible with any workrounds?

Many thanks

With that code snippet, you could optimise it further by calling the hooks without the form ID number i.e add_filter( 'gform_pre_render', 'populate_choices' ); and then checking the form name directly using the $form array:

function populate_choices( $form ) {
 
    //don't run this function if the form title doesn't match
    if ( $form['title'] != 'My Form Name Here' ) {
       return $form;
    }

As for [gravityforms] shortcode usage, I couldn’t find it in Gravity Forms documentation, but a quick look through the codebase says this is perfectly valid [gravityforms name="New Patient Registration"].

Have fun!

1 Like

Thank you very much for your reply, this is for multi site and gets over some management issues.

As for the shortcode, I thought I’d used name in the past but like you couldn’t find it in the documentation. Off to have fun.

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.