Skip Navigation

[Resolved] Added Mime types not working in CRED frontend form

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Tagged: 

This topic contains 25 replies, has 2 voices.

Last updated by rubenB 6 years, 1 month ago.

Assigned support staff: Waqas.

Author
Posts
#288036

Hi,
I'm trying to allow users to upload .gpx or .kml files via the cred form.
I've put it online here hidden link

To allow .gpx & .kml upload I've added some MIME types using PJW Mime Config Plugin.

This works fine for posting from the back end inside the Types custom field.

I'm only guessing the MIME types are the issue because can post a .jpg using the same form successfully.

Here is a sample of a .gpx files hidden link

I've referred to https://toolset.com/forums/topic/cred-not-allowing-upload-of-pptx-files/
The resolution seems to be
"the problem has been identified, the upcoming release will resolve this issue"

I'm using version 1.3.5 which I just downloaded from this site.

Thanks heaps for your help to solve this problem,

#288207

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Can you please try the solution to add more mime types to WP, as described here hidden link ?

Please let me know if it works for you. Also mention, the type of custom field (in Types).

#288324

Hello Waqas thanks for your assistance.

I've disabled PJW MIME config plugin and added this functions.php to my child theme

<?php

add_filter('upload_mimes','add_custom_mime_types');
	function add_custom_mime_types($mimes){
		return array_merge($mimes,array (
			'gpx' => 'application/gpx',
			'kml' => 'application/vnd.google-earth.kml+xml',
			'kmz' => 'application/vnd.google-earth.kmz+xml'
			));
}

I am still able to upload gpx, kml and kmz via the back end, but not the Cred form (or atleast the form won't submit if I've added these file types).

I've also tested disabling all the map plugins in case they might have added the gpx MIME type somewhere else.

The Types Custom Field in use is a 'file field'

#288425

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I just reproduced the same thing on my local host and found the same issue.

I have reported this to relevant Dev Team. I will update you as soon as I hear back.

Thank you for your cooperation and patience.

#289457

HI Waqas, thanks for helping to solve this issue,
we are eagerly awaiting to hear any ways to solve this,
if it will take a while please let us know a rough timeframe,
Thanks again.

#289536

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I apologize for the delay in this matter, but as a matter of fact, due to high load times this matter is still under observation. I will update you as soon as I hear back.

Thank you for your patience and cooperation.

#289887

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I have just sent you the latest trunk version of CRED (via WeTransfer.com) to your email address. Please download and replace with existing installation of the CRED plugin. Please remember to take backup of your site before proceeding.

Also, please add following code to your functions.php, in order to get it work:

add_filter('[image|audio|video|file]_upload_mimes', 'add_custom_mime_types');
function add_custom_mime_types($mimes){
	return array_merge($mimes, array (
		'[extention]' => '[filetype]',
	));
}

Please adjust the first parameter of add_filter() to the appropriate filter. This version adds following new filters:

add_filter('audio_upload_mimes','add_custom_mime_types');
add_filter('image_upload_mimes','add_custom_mime_types');
add_filter('video_upload_mimes','add_custom_mime_types');
add_filter('file_upload_mimes','add_custom_mime_types');

So you should use audio, image, video and/or file filter as needed (without the square brackets in first code snippet).

Please let me know if it fixes the issue, thanks.

#289904

Thanks for sending the update version 🙂

There is still the same issue, except now it gives the error message:
"The post was not saved because of the following problem:
Map File File Type Error"

The functions.php is edited as suggested

add_filter('file_upload_mimes','add_custom_mime_types');

function add_custom_mime_types($mimes){

	return array_merge($mimes, array (
'gpx' => 'application/gpx',
			'kml' => 'application/vnd.google-earth.kml+xml',
			'kmz' => 'application/vnd.google-earth.kmz+xml'
			));

}

Again this works in the dashboard post editor but not the cred form :/
Any ideas?

Cheers,

#290104

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your feedback. I have forwarded this to the relevant Dev Team. I will update you as soon as I hear back.

Thank you for your patience and cooperation.

#290180

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I have just sent you another patched version to your email address (via WeTransfer.com). Please download and replace with current installation of CRED.

The Dev Team has made some change like centralized mime types with WP ones. Now you can add/remove mime types using:

add_filter('upload_mimes','add_custom_mime_types');
function add_custom_mime_types($mimes){
return array_merge($mimes,array (
'gpx' => 'application/gpx'
));
}

or

add_filter('file_upload_mimes','add_custom_mime_types');
function add_custom_mime_types($mimes){
return array_merge($mimes,array (
'gpx' => 'application/gpx'
));
}

Please test and let me know if this resolves the issue or not, thanks.

#293243

Hello Waqas,
I'm really sorry I was working on another job in the meantime.
Now the wetransfer link has expired, if possible could you please send through again,
Thanks again

#293265

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I have just sent you the patched version again to your email address (via WeTransfer.com). Please download and replace with current installation of CRED.

And follow the instructions as mentioned above (https://toolset.com/forums/topic/added-mime-types-not-working-in-cred-frontend-form/#post-290180).

#293279

Thanks for re-upload.

Now I am getting error message:

The post was not saved because of the following problem:
Invalid Form Submission (nonce failure)

I have tested this with both upload_mimes and file_upload_mimes filters with the same result

#293359

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your feedback. I have forwarded this to the relevant dev team. I will update you as soon as there's a progress.

#293361

Waqas
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I just got an update from the team. A new version of CRED 1.3.6 was released a couple days ago. Can you please upgrade to that version and try again. Since the new version contains the same implementation and several other fixes.

Please let me know, thanks.