Prevent filtering of form uploads, but just for one form

By: Michelle Keyo | Asked: 08/23/2023
ForumsCategory: Code SnippetsPrevent filtering of form uploads, but just for one form
Michelle Keyo asked 11 months ago
I'm using some code so that form uploads appear in the media library (https://formidableforms.com/knowledgebase/file-upload/#kb-prevent-filtering-of-form-uploads), but I'm wondering if anyone has managed to do this for a specific form instead of for all forms. Any help or tips would be appreciated.   Thanks!
2 Answers
Victor Font answered 11 months ago
The pre_get_posts action is a WordPress hook that fires after the query variable object is created, but before the actual query is run. You may not be able to detect the form in use on the page with this action unless the form_id is embedded in the query variable object. This means you have to examine the object to see what it contains. If the form ID is is in the query object, you can use a conditional statement to wrap the remove action statement.
Victor Font replied 11 months ago

Alternatively, you can use a standard WordPress conditional to wrap this action based on the page/post the form is embedded within. See these articles:

https://developer.wordpress.org/reference/hooks/pre_get_posts/
https://developer.wordpress.org/reference/functions/is_page/

Michelle Keyo answered 11 months ago
Thanks for this. I'll take a look and see if I can get it working.  

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right