Contact Form 7
Running PHP code on success, passing variables (2 posts)

  1. dportela
    Posted 3 years ago #

    Here's how I want things to work:

    1. User submits form successfully.
    2. User's name and email get added to mailing list, if they have ticked a box.

    I have looked into the CF7 Database plug-in, but that only saves to the WordPress database, and I need the values saved to another database which already runs our newsletter. So I need to run some PHP code when CF7 successfully sends the email. As far as I can tell there's no way to attach the code to the form itself, so the only way would be to redirect to a page that does this…but then I would have to pass the form variables onto the "thank you" script that adds them to the database.

    So I guess there could be three solutions to this issue:

    • A plug-in that takes CF7 input and saves selected fields to a database and table that the admin selects, or
    • a way to set form-specific PHP to be executed upon a successful send, or
    • a way to pass on CF7 form values to a page being redirected to, so that it can perform the same thing.

    I appreciate any help!


  2. biswajeet
    Posted 3 years ago #

    Hi; upon checked add to mailing list and on submit you can grab the form fields and INSERT to DB using ajax. Simple!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic