Hey, thanks for the suggestion!
I’ll add this in the next release, are there any other additions you’d like to see along with this one?
I’ll try to push this change tomorrow.
We’ve added this to the latest version 1.2.8
Thanks again for the suggestion.
-
This reply was modified 2 years, 12 months ago by
Ali Khallad.
Thread Starter
niznet
(@niznet)
Thanks for the update! I will make another one when I come up with another suggestion.
Thread Starter
niznet
(@niznet)
Hi, I don’t know if this existed, but I do think that we also need to have the post id as a reference attached to the form submission (wp hook) in case we need to do something with the fields and post itself.
I’m planning to provide a feature that is able to save specific cells from google spreadsheet into the attached form post as metadata.
Currently, WP Hook only provides an array of submitted fields, maybe it can be like,
[
'id' => '1', // form id
'post_id' => 2, // post id, or maybe reference_id
'fields' => [] // submitted form fields
]
May I ask at what stage are you interacting with this array? what hook are you using and what do you need this info for?
Note that Mega Forms does not interact with the posts table, it has it’s own forms table so there is no post ID at any stage.
If you need to pull specific data, just let me know what info is available for you and what you need to pull and I’ll share the correct steps.
Thread Starter
niznet
(@niznet)
I’m using WP Hook in creating a feature to let my client input specific cells of google Sheets in a custom field, and store the specified cells to the post as metadata that uses the form. Unfortunately, WP Hook doesn’t provide what post id that the form was submitted from.
For now, I’m doing a workaround to make the client put the post id at the end of WP Hook name.
WP Hook Name: mf_spreadsheet
Workaround: mf_spreadshet_123
*123 is the post id, so I can know where the form was displayed and submitted
Hence suggested a new WP Hooks array structure,
[
'id' => '1', // form id, since it has own table
'post_id' => 2, // post id, where the form submitted from
'fields' => [] // submitted form fields
]
or as arguments something like,
function handle($fields, $post_id, $form_id)
I see, the WP Hook action will only provide submission values at this stage and we wanted to keep the values passed to a minimum to avoid complexities. The reason for this is because there are other hooks for submissions that holds all the details. We plan to extend this with more actions in the future, these actions will have more data and we want to do it correctly.
Could you use this hook “mf_submission_completed” or this one “mf_process_entry_actions”? would they work for your case, if not I’ll go ahead and make the necessary adjustements to include form id in the action. However, for post ID, we do not collect this info, but you could use get_page_by_path core function and pass the “referrer” slug from the entry data to it to retrieve the post id.
Let me know if this help, or we still need to make adjustements to the plugin.
Thread Starter
niznet
(@niznet)
I will try the get_page_by_path. Does “mf_submission_completed” or “mf_process_entry_actions” provide WP Hook data if it is configured? or at least the form id?
The “mf_process_entry_actions” should provide everything you need.
It’s created like this:
do_action('mf_process_entry_actions', $entry_id, $entry_meta, $this->form, $this->submission_values);
As you see, it holds the entry id, entry meta, the form object, and the submission values. If you need more info, there are functions to pull extra data from entry and form.
Thread Starter
niznet
(@niznet)
Thanks! That should fulfill what I need.
That’s great, let us know if you need anything else 🙂