How can we help?

Table of Contents

Add Support for a Custom File Type in File Uploader

By default, the MainWP File Uploader Extension doesn’t support all file types. By using the mainwp_file_uploader_allowed_file_types filter, it is possible to add support for any file type.

In this example, we will show how to add support for the JSON file type:

  1. Install and activate the MainWP Custom Dashboard extension
  2. Go to the PHP section (MainWP > Extensions > Custom Dashboard > PHP)
  3. Paste the following code snippet and Save Chagnes:
add_filter('mainwp_file_uploader_allowed_file_types', 'mycustom_mainwp_file_uploader_allowed_file_types');
function mycustom_mainwp_file_uploader_allowed_file_types( $types ) {
   $types[] = 'json';
   return $types;
}

 

Still Have a Questions?
Search for additional solutions in the MainWP Community or start your own discussion