• I have multiple forms on my website and I want them to be prefilled by the logged-in user’s last entries everytime they load the page.
    CF7DB saves contact forms entries to the database. I handle the data query in functions.php in my child theme. On form loading, using the prefill hook, I get the user’s last record from “_db7_forms” table and return it. BUT if the user submits form A and then tries to open form B, it returns the last entries of form A!
    I can fix it:
    * if I Have a hidden field to send form key. Then I can iterate through rows to find the last entry that is corresponded to the form. Please let me know if there is a tag to get the form key as a hidden field.
    * If I can get the ‘from_post_id’ in function.php, when ‘cf7sg_prefill_form_fields’ is applied. (post id as argument)
    But right now, there is no obvious way to find the right data entry. Hook has “cf7_key” which is not in DB and records have ‘from_post_id’ which is not in filter arguments.
    please guide me if you have a solution.|
    Thank you very much.

Viewing 1 replies (of 1 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    the ‘cf7_key’ can be interchaged with the form ‘id’ using the following function,

    form_id = get_cf7form_id($cf7_key)

    I don’t use CF7DB so I can’t be of much help. My other plugin Post My CF7 Form is designed to save form submissions as posts (much more versatile than saving them into a db table), and has built-in functionality to reload draft submissions or submitted forms for given users.

Viewing 1 replies (of 1 total)
  • The topic ‘Form ID as hidden field’ is closed to new replies.