How to delay processing for frm_validate_field_entry to complete before frm_after_create_entry triggers ?

By: Hans Baumhardt | Asked: 05/02/2023
ForumsCategory: Code HelpHow to delay processing for frm_validate_field_entry to complete before frm_after_create_entry triggers ?
Hans BaumhardtHans Baumhardt asked 12 months ago

I have a form which includes a file upload field.  

 

A frm_validate_field_entry function on a following hidden field parses EXIF GPS metadata from the file upload via the attachmentID to fill itself (and some other preceeding hidden fields).  

 

The problem is that sometimes (not always) functions that depend on reading the attached file just return blanks, as if the form has already completed POST before the function has returned so the attached file handle is no longer valid.  

 

ALTHOUGH the function variables which point to the file still return values:  

 

$attachment_id = $_POST['item_meta'][$upload_field_id];  

 

$attachment_handle = get_attached_file($attachment_id);

 

  ... in the error condition using them returns nothing:   

 

$exifdata = @exif_read_data($attachment_handle, 0, false, false);  

 

Moving the hidden field with its parsing function up the form helps reduce the incidence, but it is not a 100% solution as I still see frm_after_create_entry triggering in a debug log BEFORE the frm_validate_field_entry field function has completed causing the blank returns.  

 

TL;DR: is there any way of stopping/blocking/locking an entry being created and clearing handles BEFORE  all frm_validate_field_entry functions have completed ?  

 

ps apologies for double spacing, this editor seems to ignore simple CRs.

1 Answers
Victor Font answered 12 months ago
Have you tried changing the priority on the frm_validate_field_entry hook so it fires earlier?
Hans BaumhardtHans Baumhardt replied 12 months ago

Good call, unfortunately its already the lowest add_filter priority on that server/script at 10, all others are higher at 20, 30, 40.

Victor Font replied 12 months ago

You can set priorities lower than 10. 10 is only the WordPress default.

Victor Font replied 12 months ago

Another thought..., does you form have embedded forms for repeaters? They get processed first before the main form.

Hans BaumhardtHans Baumhardt replied 12 months ago

No its simple upload file and fill in a couple of fields/sliders page.

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