How to get Media Library attachment id (post id) of uploaded file?
-
I’m using a Forminator file upload form and have code that will add metadata to the DB when someone uploads a file (via the hook ‘forminator_custom_form_submit_before_set_fields’).
But I’m trying to get the ‘post id’ of the newly uploaded file as it is in the Media Library. I’ve enabled the Forminator option to “Show files in Media Library”.
I want to be able to take the Forminator ‘entry_id’ and look up the ‘post id’ of the file upload.
My code is able to see the details about the file that is uploaded, but it only shows the Forminator info, such as:
[entry_id] => 39 [entry_type] => custom-forms [form_id] => 138
I can’t find a way to get the WordPress ‘post id’ of the uploaded file from the Forminator ‘entry_id’. Is this possible? I need it to be able to set metadata for the newly uploaded file.
Or, if Forminator can provide the URL of the file, I can look it up that way, but neither ‘post id’ nor ‘image url’ get passed in via the hook, just the Forminator details such as ‘entry_id’.
- The topic ‘How to get Media Library attachment id (post id) of uploaded file?’ is closed to new replies.