WordPress.org

Forums

Contact Form 7
[resolved] 3.9 Breaks CFDB Plugin (25 posts)

  1. Michael Simpson
    Member
    Posted 9 months ago #

    I'm the author of CFDB which captures CF7 form submissions and saves them to the DB.

    The plugin listens to the wpcf7_before_send_mail hook and pulls the form submission data from the object passed in ($object->posted_data) but "posted_data" no longer appears. The passed in object does have the form definition information, but has none of the form submission data.

    Anyone else relying on wpcf7_before_send_mail to do something with with the data will also have this problem.

    Please advise on how data can be collected in version 3.9. Many sites are rely on both these plugins.

    Thank you.

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 9 months ago #

    Hi Michael,

    Use this instead:

    $submission = WPCF7_Submission::get_instance();
    
    if ( $submission ) {
    	$posted_data = $submission->get_posted_data();
    }
  3. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 9 months ago #

  4. Rene Hermenau
    Member
    Posted 9 months ago #

    @Takayuki Mioyshi

    Maybe its a good idea if you create a short sticky topic here, what people have to do when they run into troubles with the latest version of cf7? So hopefully they look first on the sticky topic and duplicate questions can be reduced. We can also write a FAQ there.

    Maybe some title like:

    IMPORTANT: FAQ CF7 3.9 Common issues.

    Btw. Thanks for the latest update. I love it! Thanks for it:-)

    Best,
    René

  5. sm1372
    Member
    Posted 9 months ago #

    @Takayuki Mioyshi

    $submission = WPCF7_Submission::get_instance();

    if ( $submission ) {
    $posted_data = $submission->get_posted_data();
    }

    NOT WORK!!!!

    CFDB after contact form updated to last version , don't save any data in DB table and only create new row!

    please help me!!!

  6. fl0ri
    Member
    Posted 9 months ago #

    I seriously need a fix here. All our feedback data collection relies on the working combination of "Contact Form 7" and "CFDB". Please try hard!

  7. Michael Simpson
    Member
    Posted 9 months ago #

    i'm working on it right now

  8. Michael Simpson
    Member
    Posted 9 months ago #

    I just pushed version 2.8.2 to mostly fix the issue. It should appear as an available update shortly.

    @Takayuki
    I still seem to have a problem. When I click the submit button on my form I do get the data saved and an email sent to me, but the form shows the spinning wait icon and it doesn't go away. It looks like the form is stuck. I return "true" from my function hooked up to wpcf7_before_send_mail. Any thoughts on what would be causing that?

    Thanks.

  9. s_nickpour
    Member
    Posted 9 months ago #

    Hello
    i just updated contact form 7 to 3.9 but after that the contact form 7 database extension(CFDB) does not work properly and the submission data does not show and the fields look empty
    please fix this...
    it is better that the authors of these 2 plugins have better cooperation and before releasing new versions,discuss about these probable errors
    beacause millions of sites are using these 2 plugins together

  10. fl0ri
    Member
    Posted 9 months ago #

    @Michael: Thank you very much. I truly appreciate it.
    @s_nickpour: I just applied Michaels update and on my installation it seems to be fixed. (CFDB 2.8.2 + CF7 3.9). Mails are sent, values appear in the database.

  11. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 9 months ago #

    @msimpson Michael, maybe I can find out the cause of the issue if I can check the site having the issue. Can I have the URL?

  12. Michael Simpson
    Member
    Posted 9 months ago #

    @Takayuki
    I think I have it resolved. My code was accessing WPCF7_ContactForm::title directly which is now private. This works to get the data but seems to cause a side-effect. Using the WPCF7_ContactForm::title() method seems to fix it.

  13. sm1372
    Member
    Posted 9 months ago #

    @Michael Simpson

    Finally can you help me how to fix it?

    conflict with last version of contact form 7 and cfdb!

  14. Michael Simpson
    Member
    Posted 9 months ago #

    What do you mean by "conflict"?

  15. sm1372
    Member
    Posted 9 months ago #

    SOLVED with update for CFDB 2 mins ago ...

  16. Jason
    Member
    Posted 9 months ago #

    Our library is set up to collect data using wpcf7_before_send_mail, which redirects the data into a database so I can generate graphs from it, and we've just lost over 3 hours of work.

    Is there a quick way to get this back online? Damn things made me look incompetent.

    Is there any way to downgrade to 3.8 or something? I need to fix this and I'd rather keep the validation instead of just writing my own form/shortcode.

  17. Rene Hermenau
    Member
    Posted 9 months ago #

    You can download and install the old 3.8 version from here:
    http://downloads.wordpress.org/plugin/contact-form-7.3.8.1.zip

    Make sure to have a complete backup before deleting the 3.9 and installing the old version. Than you should be able to restore the old form within minutes.

  18. Jason
    Member
    Posted 9 months ago #

    Mmm Now I just have to figure out why WordPress is telling me that the contents of the zip file are empty.

  19. Rene Hermenau
    Member
    Posted 9 months ago #

    Rename the zip folder into contact-form-7.zip. Does this work? Maybe zip file has been corrupted due download?

  20. Michael Simpson
    Member
    Posted 9 months ago #

    Some code that might help for backward compatibility:
    1. Take your old function hooked to wpcf7_before_send_mail, say it was called "hook", and rename it to something else, say "hook1"
    2. Create a new version of "hook" that changes the data back to what it was before, then passes it to the original (now renamed) hook1:

    function hook() { // change to your function name
      $submission = WPCF7_Submission::get_instance();
      if ($submission) {
        $data = array();
        $data['title'] = $cf7->title();
        $data['posted_data'] = $submission->get_posted_data();
        $data['uploaded_files'] = $submission->uploaded_files();
        $obj = (object) $data;
        hook1($obj); // call the original function (now renamed)
      }
      return true;
    }
  21. Michael Simpson
    Member
    Posted 9 months ago #

    @Takayuki Mioyshi - minor thing:

    With regard to this code:

    $submission = WPCF7_Submission::get_instance();
    if ( $submission ) {
      $posted_data = $submission->get_posted_data();
    }

    Would you consider having get_posted_data() return a reference to the array? (or supply an additional method to do this)

    I have situations where users want to change the data that is submitted before it is saved. They do that using a "hook in my CFDB plugin but can also do this using your wpcf7_before_send_mail hook directly (see below).

    Prior to CF7 3.9, the hooks operated on a reference to the posted_data. Now they have a copy. For my purposes (changing some data before it is saved) it still works. But before CF7 3.9, when users modified the posted_data, they would see those changes in the email that CF7 sends out. Now they don't.

    Here is my simplistic example. I have a form with a "name" field. I put in a simple hook for the purpose of upper-casing the name text submitted (calling ucfirst). I put in this hook:

    function cf7_ref_test() {
      $submission = WPCF7_Submission::get_instance();
      if ($submission) {
        // would like to get posted_data as a reference
        $data =& $submission->get_posted_data();
        if (isset($data['name'])) {
          $data['name'] = ucfirst($data['name']);
        }
      }
    }
    add_action('wpcf7_before_send_mail', 'cf7_ref_test');

    Although the hook is called, the email that I get from CF7 does not have the change because $submission->get_posted_data() returns a copy of the array.

  22. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 9 months ago #

    You can use wpcf7_posted_data filter for such purposes.

  23. Michael Simpson
    Member
    Posted 9 months ago #

    I see. Unfortunately in that hook I only have posted_data, where users want to manipulate the title, posted_data, and uploaded_files just prior to saving & emailing. Users do things like conditionally map more than one form title into the same form title (to appear together in the DB) and grab the uploaded files and copy them somewhere, as well as adding & changing fields.

    To get all the benefits, they would have to register a function on wpcf7_posted_data to handle field changes that they want to see in email, then another on wpcf7_before_send_mail to handle title and uploaded files, which would not be reflected in emails. It's awkward now.

  24. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 9 months ago #

    Use the most appropriate hook for each purpose, please.

  25. slboytoy
    Member
    Posted 8 months ago #

    I have the same question as Michael and can't seem to follow along.

    I use "wpcf7_before_send_mail" to send the submitted form to a database. The database returns their unique key (insert_id). Then I would save that unique key back to the posted_data, but now posted_data is just a copy. Can't figure out how to save it back to the original, so the email will capture it.

Reply

You must log in to post.

About this Plugin

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

About this Topic

Tags

No tags yet.