Using Gravity Forms ‘gform_is_ssl’ PHP filter

The gform_is_ssl Gravity Forms PHP filter allows you to determine if the current page is running securely (https). This can be useful when using a proxy server that does not set the $_SERVER['HTTPS'] variable.

Usage

add_filter('gform_is_ssl', 'your_custom_function');
function your_custom_function($is_ssl) {
    // your custom code here
    return $is_ssl;
}

Parameters

  • $is_ssl (boolean): Indicates whether the current page is running securely (https) or not.

More information

See Gravity Forms Docs: gform_is_ssl

Examples

Force SSL for all Gravity Forms pages

Force all Gravity Forms pages to use SSL, regardless of the current page’s protocol.

add_filter('gform_is_ssl', 'force_ssl_for_gravity_forms');
function force_ssl_for_gravity_forms($is_ssl) {
    return true;
}

Enable SSL only for specific form

Enable SSL for a specific form with the form ID of 5.

add_filter('gform_is_ssl', 'enable_ssl_for_specific_form', 10, 2);
function enable_ssl_for_specific_form($is_ssl, $form_id) {
    if ($form_id == 5) {
        return true;
    }
    return $is_ssl;
}

Disable SSL for specific form

Disable SSL for a specific form with the form ID of 3.

add_filter('gform_is_ssl', 'disable_ssl_for_specific_form', 10, 2);
function disable_ssl_for_specific_form($is_ssl, $form_id) {
    if ($form_id == 3) {
        return false;
    }
    return $is_ssl;
}

Enable SSL based on user role

Enable SSL for Gravity Forms pages if the current user has the ‘editor’ role.

add_filter('gform_is_ssl', 'enable_ssl_for_editors');
function enable_ssl_for_editors($is_ssl) {
    if (current_user_can('editor')) {
        return true;
    }
    return $is_ssl;
}

Enable SSL for specific post type

Enable SSL for Gravity Forms pages if the current post type is ‘product’.

add_filter('gform_is_ssl', 'enable_ssl_for_product_post_type');
function enable_ssl_for_product_post_type($is_ssl) {
    global $post;
    if ($post->post_type == 'product') {
        return true;
    }
    return $is_ssl;
}