Adding gform_pre_render and a function without any code in it breaks the form [RESOLVED]

Adding the following code results in the “oops! We could not locate your form.” error.

add_filter( ‘gform_pre_render_1’, ‘observation_form_setup’, 10);

function observation_form_setup( $form ){
//do nothing
}

If I change it to ‘gform_pre_render_2’ (a non-existent form) then form 1 works. I also tried just ‘gform_pre_render’ and that breaks the form too (this apparently worked for someone with this exact problem 10 years ago). I’ve used gform_pre_render plenty of times on other sites and never seen this problem. Any ideas on how to solve it?

Filters expect the initial parameter to be returned.

So a ‘do nothing’ example would need to at minimum be:

add_filter( ‘gform_pre_render_1’, ‘observation_form_setup’, 10);

function observation_form_setup( $form ){
//do nothing
return $form
}

D’oh! Sometimes the solution is too obvious. Thank you.

1 Like