The gform_disable_registration Gravity Forms PHP filter allows add-ons to prevent the User Registration add-on from registering/updating a user.
Usage
add_filter('gform_disable_registration', 'your_function_name', 10, 3);
Parameters
- $is_disabled (bool): True or false.
 - $form (Form Object): The submitted form object.
 - $entry (Entry Object): The entry object from which the user was registered.
 - $fulfilled (bool): True or false. This may be a value passed from an add-on like PayPal which indicates that the payment has been fulfilled. Null as of version 3.0.
 
More information
See Gravity Forms Docs: gform_disable_registration
Examples
Disable registration based on submitted form values
In this example, we disable registration if the submitted values for fields 4 and 5 are both “No”.
add_filter('gform_disable_registration', 'disable_registration', 10, 3);
function disable_registration($is_disabled, $form, $entry) {
    // Check form id and if not the form being checked, simply return the status passed in to function
    if ($form['id'] != 160) {
        return $is_disabled;
    }
    // Check submitted values to decide if registration should be stopped
    if (rgar($entry, '4') == 'No' && rgar($entry, '5') == 'No') {
        // Disable registration
        return true;
    } else {
        return false;
    }
}
Disable registration for a specific form
In this example, we disable registration if the form ID is 25.
add_filter('gform_disable_registration', 'disable_registration_for_form', 10, 3);
function disable_registration_for_form($is_disabled, $form, $entry) {
    return $form['id'] == 25;
}
Disable registration based on user role
In this example, we disable registration if the user role in the submitted form is “subscriber”.
add_filter('gform_disable_registration', 'disable_registration_for_role', 10, 3);
function disable_registration_for_role($is_disabled, $form, $entry) {
    $user_role = rgar($entry, '6'); // Replace '6' with the field ID containing the user role
    return $user_role == 'subscriber';
}
Disable registration based on a custom field value
In this example, we disable registration if the custom field “disable_registration” is set to “yes”.
add_filter('gform_disable_registration', 'disable_registration_custom_field', 10, 3);
function disable_registration_custom_field($is_disabled, $form, $entry) {
    $disable_registration = rgar($entry, '7'); // Replace '7' with the field ID containing the custom field value
    return $disable_registration == 'yes';
}
Disable registration based on the current date
In this example, we disable registration if the current date is after May 1, 2023.
add_filter('gform_disable_registration', 'disable_registration_based_on_date', 10, 3);
function disable_registration_based_on_date($is_disabled, $form, $entry) {
    $today = new DateTime();
    $deadline = new DateTime('2023-05-01');
    return $today > $deadline;
}