I have the following shortcode [mb_frontend_form id="dc-product-test" post_id="1" submit_button="Submit" ajax="true"]
I was wondering is it possible to update the post_id of the rendered form to "0" or something else if a user clicks on a button inside the DOM.
I am assuming there is not a clean way to do this. I want to do this so i can change the post_id to be "0". So if a user clicks on a 'duplicate' button it will create a new post with the same data rather than updating the existing post. it was just a quick way for users to duplicate listings on my website if they are on a post edit screen page.
The attribute post_id and other attributes of the form (form settings) are saved to the database in the table wp_options with the key mbfs_key. Each form has its own key based on the form settings.
So it is possible to create a new form and set the post_id to 0 and generate a new key to create a new post after submitting but you will need a lot of custom code to do that.
Instead of modifying the post_id attribute of the form, you can try to use the action hook rwmb_frontend_before_save_post and set the post_id to 0 to duplicate a post. For example: