Using Gravity Forms ‘gform_enable_password_field’ PHP filter

The gform_enable_password_field is a Gravity Forms PHP filter that enables the password field. This is useful when developing add-ons that require a password field.

Usage

add_filter('gform_enable_password_field', '__return_true');

Parameters

  • $is_enabled (bool): Value to be filtered. true enables the password field; false disables it.

More information

See Gravity Forms Docs: gform_enable_password_field

Examples

Enable the password field

This example enables the password field.

add_filter('gform_enable_password_field', '__return_true');

Disable the password field

This example disables the password field.

add_filter('gform_enable_password_field', '__return_false');

Enable the password field conditionally

This example enables the password field for a specific form ID.

function enable_password_field_for_form($is_enabled, $form) {
    if ($form['id'] == 5) {
        return true;
    }
    return $is_enabled;
}
add_filter('gform_enable_password_field', 'enable_password_field_for_form', 10, 2);

Enable the password field for admin users only

This example enables the password field only for admin users.

function enable_password_field_for_admin($is_enabled) {
    if (current_user_can('manage_options')) {
        return true;
    }
    return $is_enabled;
}
add_filter('gform_enable_password_field', 'enable_password_field_for_admin');

Enable the password field for specific add-ons

This example enables the password field only for specific add-on slug.

function enable_password_field_for_addon($is_enabled, $form) {
    $required_addon_slug = 'your_addon_slug';
    if (class_exists('GFForms') && method_exists('GFForms', 'get_registered_addons')) {
        $addons = GFForms::get_registered_addons();
        foreach ($addons as $addon) {
            if ($addon->get_slug() == $required_addon_slug) {
                return true;
            }
        }
    }
    return $is_enabled;
}
add_filter('gform_enable_password_field', 'enable_password_field_for_addon', 10, 2);