Remove Spaces & Dashes in Filenames

Code

Filename: gpfr-remove-spaces-and-dashes.php

<?php
/**
 * Gravity Perks // File Renamer // Remove Spaces & Dashes in Filenames
 * https://gravitywiz.com/documentation/gravity-forms-file-renamer/
 */
add_filter( 'gpfr_filename', function( $renamed_file, $file, $entry, $form, $field ) {

	$directory_path    = dirname( $renamed_file );
	$filename          = basename( $renamed_file );
	$modified_filename = str_replace( '-', '', $filename );

	return $directory_path . '/' . $modified_filename;
}, 10, 5 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.