Skip Navigation

[Resuelto] Custom field – File – File type restriction

This support ticket is created hace 4 años, 1 mes. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: ,

This topic contains 3 respuestas, has 2 mensajes.

Last updated by Christian Cox hace 4 años, 1 mes.

Assisted by: Christian Cox.

Autor
Mensajes
#1516435
Capture d’écran 2020-02-19 à 09.45.26.png

Hi, is there a way to restrict a custom field file to only allow .pdf?

Thanks

#1516823

Hello, there is no built-in way to limit the file types accepted by a file field, but if the posts are created with Forms you can use the Forms validation API to enforce specific file type(s). We have some information about this in several places:
https://toolset.com/errata/a-note-on-using-the-cred_form_ajax_upload_validate-hook/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_ajax_upload_validate

...and in various other tickets in the forum. This approach only works when posts are created with Forms and the Media Library is used to handle media uploads in that Form.

Let me know if you have questions about implementing this API and I can take a closer look.

#1516857

So there is no way presently to limit the file type directly in the wordpress backend? We don't use Forms

#1518863

Yes, that is correct. The only public field content validation APIs provided by Toolset are for validating Forms submissions, not uploads in wp-admin.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.