mercredi 24 juillet 2019

Check value from Gravity Forms API

I am creating a custom Gravity Forms add-on and it appears to work so far. The settings are showing and saving as expected.

enter image description here

Here's what I have:

public function plugin_settings_fields() {

    return array(
        array(
            'title' => esc_html__( 'Animal Types', 'animaltypes' ),
            'fields' => array(
                array(
                    'name' => 'gravity_forms_animal_types',
                    'type' => 'checkbox',
                    'label' => esc_html__( 'Animal Types', 'animaltypes' ),
                    'choices' => array(
                        array(
                            'label' => esc_html__( 'Cat', 'animaltypes' ),
                            'name' => 'option_cat',
                            'default_value' => 0,
                        ),
                        array(
                            'label' => esc_html__( 'Dogs', 'animaltypes' ),
                            'name' => 'option_dog',
                            'default_value' => 0,
                        )
                    )
                ),
            )
        )
    );
}

But what I can't figure out is how to check, for example, if option_cat has been set so that I can then run a custom function if it is.

So essentially (and I know the below code is not correct) something like this:

if(option_cat == true) {
    my_cat_function();
}

Aucun commentaire:

Enregistrer un commentaire