Skip Navigation

[Gelöst] Custom field – File – File type restriction

This support ticket is created vor 2 Jahre, 11 Monate. 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.

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)

This topic contains 3 Antworten, has 2 Stimmen.

Last updated by Christian Cox vor 2 Jahre, 11 Monate.

Assigned support staff: Christian Cox.

Author
Artikel
#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.