A user can only send images as attachment

I've made some tests with the plugin - which is brilliant, by the way. A user sent a txt file as an attachment. No notification that the file was not attached, and I didn't receive anything. Once the user tried with a png file, I received the attached image. I don't mind attaching only images, I wouldn't mind to have the option to remove the "attach file" button. But, can you tell me how can I modify or add the text that users should only upload images?
Something like: "Attachments - only png, jpg files allowed)

The way the plugin works now they could try to upload anything, since they don't know I'm not receiving the attached files. On the other side, I wouldn't know that they tried to attach files. Or I'm doing something wrong...?

Thank you

  • Patrick
    • Support Monkey

    Hi there @Marius

    I hope you're having a great day!

    I believe the restriction on the txt filetype is for security as malicious code can be uploaded to your site via txt file.

    So, basically you have 2 options: either modify the allowed filetypes (not recommended) or modify the text string that displays on the Support screen on your network sites.

    To modify the text string, the most update-proof way is to create a custom language file for the plugin using a program like PoEdit:

    The language files you create for this plugin should be named:

    Be sure to change the locale (the en_US part) to the correct language code used on your site. Also, be sure WP_LANG is defined in your wp-config.php file.

    However, if you really want to modify the allowed filetypes, you can leverage a filter in the plugin by creating your own plugin to upload to your wp-content/mu-plugins folder.

    Something like this should work:

    Plugin Name: My Allowed Filetypes for Support
    Description: Modifies allowed filetypes for the Support System plugin
    function my_custom_allowed_filetypes() {
    	$allowed_file_types = array(
    		'jpg' =>'image/jpg',
    		'jpeg' =>'image/jpeg',
    		'gif' => 'image/gif',
    		'png' => 'image/png',
    		'zip' => 'application/zip',
    		'gz|gzip' => 'application/x-gzip',
    		'rar' => 'application/rar',
    		'pdf' => 'application/pdf',
    		'doc' => 'application/doc',
    		'doc' => 'application/docx',
    		'txt' => 'application/txt',
    add_filter( 'incsub_support_allowed_mime_types', 'my_custom_allowed_filetypes' );

    Please let us know how it goes for you, and if you need more help with this.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.