Using Gravity Forms ‘gform_user_registration_is_new_file_upload’ PHP filter

The gform_user_registration_is_new_file_upload filter in the Gravity Forms User Registration Add-On allows you to change whether new files have been uploaded when an Update User feed is processed.

Usage

add_filter('gform_user_registration_is_new_file_upload', 'upload_custom_action', 10, 3);

Parameters

  • $is_new_file_upload (bool) – Whether new files have been uploaded.
  • $form_id (int) – The current form ID.
  • $input_name (string) – The current input name.

More information

See Gravity Forms Docs: gform_user_registration_is_new_file_upload

This filter was added in User Registration version 4.9. The source code can be found in GF_User_Registration::is_new_file_upload() in gravityformsuserregistration/class-gf-user-registration.php.

Examples

Custom Upload Action

Control whether new files are considered uploaded based on custom logic.

function upload_custom_action($is_new_file_upload, $form_id, $input_name) {
    // your custom code here
    return $is_new_file_upload;
}
add_filter('gform_user_registration_is_new_file_upload', 'upload_custom_action', 10, 3);

Always Consider New Files Uploaded

Override the default behavior to always consider new files uploaded.

function always_new_files($is_new_file_upload, $form_id, $input_name) {
    return true;
}
add_filter('gform_user_registration_is_new_file_upload', 'always_new_files', 10, 3);

Never Consider New Files Uploaded

Override the default behavior to never consider new files uploaded.

function never_new_files($is_new_file_upload, $form_id, $input_name) {
    return false;
}
add_filter('gform_user_registration_is_new_file_upload', 'never_new_files', 10, 3);

Change Behavior Based on Form ID

Alter the file upload behavior based on the form ID.

function form_specific_new_files($is_new_file_upload, $form_id, $input_name) {
    // Only consider new files uploaded for form ID 2
    return $form_id === 2;
}
add_filter('gform_user_registration_is_new_file_upload', 'form_specific_new_files', 10, 3);

Change Behavior Based on Input Name

Alter the file upload behavior based on the input name.

function input_specific_new_files($is_new_file_upload, $form_id, $input_name) {
    // Only consider new files uploaded for input named 'file_upload'
    return $input_name === 'file_upload';
}
add_filter('gform_user_registration_is_new_file_upload', 'input_specific_new_files', 10, 3);