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?
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"].