Using Gravity Forms ‘gform_signature_url_require_login’ PHP filter

The gform_signature_url_require_login Gravity Forms PHP filter can be used to require the user to be logged in before the signature URL will allow access to the file.

Usage

add_filter('gform_signature_url_require_login', 'your_function_name', 10, 3);

Parameters

  • $require_login (bool): Does the user need to be logged in to access the signature? Default false.
  • $form_id (int): The ID of the form used to create the requested signature.
  • $field_id (int): The ID of the field used to create the requested signature.

More information

See Gravity Forms Docs: gform_signature_url_require_login

Examples

Require login for all forms

add_filter('gform_signature_url_require_login', '__return_true');

Require login for specific form and field

add_filter('gform_signature_url_require_login', 'require_login_for_signatures', 10, 3);

function require_login_for_signatures($require_login, $form_id, $field_id) {
    // Update values below to match your form and field id's
    if ($form_id == '97' && $field_id == '2') {
        $require_login = true;
    }
    return $require_login;
}

Require login based on user role

add_filter('gform_signature_url_require_login', 'require_login_based_on_user_role', 10, 3);

function require_login_based_on_user_role($require_login, $form_id, $field_id) {
    if (current_user_can('subscriber')) {
        $require_login = true;
    }
    return $require_login;
}

Require login for specific form but not for specific field

add_filter('gform_signature_url_require_login', 'require_login_for_specific_form_exclude_field', 10, 3);

function require_login_for_specific_form_exclude_field($require_login, $form_id, $field_id) {
    if ($form_id == '97' && $field_id != '2') {
        $require_login = true;
    }
    return $require_login;
}

Require login for specific field across all forms

add_filter('gform_signature_url_require_login', 'require_login_for_specific_field_all_forms', 10, 3);

function require_login_for_specific_field_all_forms($require_login, $form_id, $field_id) {
    if ($field_id == '2') {
        $require_login = true;
    }
    return $require_login;
}