Want to restore data to contact form 7, wordpress

2019-08-03 22:47发布

问题:

My site got hacked and in the end I had to remove the entire WordPress installation and database. My biggest problem now is that I used the Contact Form 7 with a very large number of contacts and it is no longer in my database since I had to make a new one. I did manage to make a backup of the tables containing the contact form data (as SQL and XML). But I don't know if it's possible to restore the data from the backed up tables to the new ones? I don't want to drop the new tables and replace them with the backed up ones (and alter the names of the tables), because I'm not sure if the constraints get the correct name and so on. The database is MySQL via phpMyAdmin

So, essentially I want to move data from one table to a new! Is it possible?

EDIT: Så I imported the old contact form tables, with new names, and it didn't work. BUT, when I reverted to an older version of contact form, it worked. Seems there is a difference in how the versions handle and stores the data. But now I can't upgrade it! As soon as I do, all my contacts disappear. Does anyone know how to fix it, or why it behaves this way?

回答1:

Contact Form 7 holds all its data in wp_contact_form_7 table (assuming your table prefix is wp_) and doesn't assign forms to pages with a typical database key relationship. Rather, it will place a marker in your page content that gets interpreted and replaced by the plugin and renders the proper form based on the name it finds in your post.

Assuming all your pages & posts have been imported back into your new DB the way it was before, and you've already got CF7 enabled as a plugin, you should be able to import the old contact_form_7 table into your new database from phpMyAdmin without issue.

As always, make a backup of your new database as well in case something goes wrong.