Back to Community

How to Allow Specific File Types in Fluent Forms Upload Fields

11 threads Sep 10, 2025

Content

When creating a job application or document submission form with Fluent Forms, you might need to restrict the types of files users can upload. By default, the plugin allows common file types, but you may have a specific requirement to only accept formats like PDF, JPG, DOC, and DOCX. This guide explains how to implement this customization.

Why This Customization is Necessary

The Fluent Forms plugin does not include a built-in setting in its user interface to define a custom, restricted list of allowed file types for its file upload field. To enforce a specific list of acceptable formats (e.g., pdf|jpg|doc|docx), you need to add a small piece of custom code to your website. This approach provides precise control over the files users can submit through your forms.

How to Restrict File Types

The solution involves adding a custom PHP code snippet to your website. The code will modify the allowed file types for Fluent Forms' upload fields globally.

  1. Access the Code Snippet: The Fluent Forms team provides an official code snippet on their GitHub repository that serves as a perfect template. You can view the original example for allowing PSD and AI files here: GitHub Code Snippet.
  2. Modify the Code for Your Needs: You will need to adapt this code to allow only your desired file types. The following code is modified to accept only pdf, jpg, doc, and docx files.
    
    add_filter('fluentform/upload_valid_file_types', function ($extensions, $field) {
        // Define your allowed extensions here
        $allowedExtensions = ['pdf', 'jpg', 'doc', 'docx'];
        
        // Return the new list of allowed extensions
        return $allowedExtensions;
    }, 10, 2);
    
    
  3. Add the Code to Your Site: There are two common methods for adding this custom code:
    • Using a Code Snippets Plugin: Install a plugin like "Code Snippets." Create a new snippet, paste the modified code from above, and activate it. This is the safest and easiest method, as it avoids directly editing your theme's files.
    • Editing your theme's functions.php file: You can also add this code to your active theme's functions.php file. It is highly recommended to use a child theme if you choose this method to prevent your changes from being lost during theme updates.
  4. Test the Form: After adding the code, clear any caching on your site and test the file upload field in your form. It should now reject any file that does not have a .pdf, .jpg, .doc, or .docx extension.

Important Considerations

  • This code will affect all file upload fields across all Fluent Forms on your website. If you need different rules for different forms, a more advanced, conditional code would be required.
  • Always test functionality on a staging site before implementing it on your live website.
  • As with any custom code, ensure it is kept updated and compatible with the latest versions of WordPress and Fluent Forms.

This method, as confirmed by users in the support forums, is an effective way to gain control over the file types submitted through your forms.