gform_file_permission

Description

The gform_file_permission filter allows developers to change the default permissions of uploaded files. It runs when uploading a file.

Usage

Applies to all forms.

add_filter( 'gform_file_permission', 'set_file_permission', 10, 2 );

Parameters

ParameterTypeDescription
$permissionstringThe file permission to be filtered (i.e. 0755).
$pathstringThe full file path.

Examples

Change the permissions of uploaded files to 0755.

add_filter( 'gform_file_permission', 'set_file_permission', 10, 2 );
function set_file_permission( $permission, $path ) {
	// Note the octal value with the leading zero. Don't return a string.
	return 0755;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in GFFormsModel::set_permissions() in forms_model.php.