Forms keep turning "inactive" when we edit them

It is not uncommon in our organization to edit a form which is currently in use.

However, we’ve seen a number of times lately (not sure if it’s perfectly consistent or not) that when we edit an “active” form, it automatically switches to “inactive”. This is a frustrating and confusing behavior for our users.

Is there any way to turn this off if it is a “feature”? Or, has anyone seen this before, if it is a bug?

We are running GF 2.7.16 on a multisite install.

I’m not experiencing the issue in a default WordPress installation. I recommend you to proceed with a conflict test: https://docs.gravityforms.com/testing-theme-plugin-conflict/

Hi @sacom ,
I’ve narrowed this issue down to this filter in our plugin:

add_action( 'gform_after_save_form', function ( $form, $is_new ) {
	$form['enableHoneypot'] = true;
	GFAPI::update_form( $form );
}, 10, 2 );

For some reason, when this code is in place, every (or many) edits to the form change it to inactive. It’s odd to me, since it’s nearly identical to what is in the example for this action.

I can see that when the $form variable comes into this action, it always has $form['is_active'] = 0, regardless of whether the form is active or not. I don’t know if that has anything to do with this or not.

That’s expected. The $form object passed to gform_after_save_form doesn’t contain the is_active property, so when GFAPI::update_form runs the is_active property is not found in the $form object. You need to include $form [ 'is_active' ] = '1'; in your snippet as shown in the third example of the filter documentation.

Ok, I see. Thank you. What happens if someone is editing an inactive form? If the incoming $form object doesn’t contain the is_active property, is there any way to know for sure whether the form was intended to be active or inactive?

On our testing instance (with the same code in place), the exact opposite behavior happens. All forms are forced to “active”, even those that are supposed to be inactive.

When inspecting the incoming $form['is_active'] property (which is present by the way), I can see that it’s always 1 on our testing instance (and then forms are forced to active), and it’s always 0 on our prod instance (and then forms are forced to inactive).

I have no other Gravity Forms plugins active.

When I do call get_form( $form['id'] ) inside the action like this:

add_action( 'gform_after_save_form', function ( $form, $is_new ) {
    $fetched_form = GFAPI::get_form( $form['id'] );
    # $fetched_form['is_active'] is accurate
    # $form['is_active']  is not accurate.
    GFAPI::update_form( $form );
}, 10, 2 );

The fetched form has an accurate is_active property, while the incoming $form object in the action does not. I believe this is a bug.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.