Version Description
- Disabled saving mail2 by default. Overridable with filter wpcf7s_save_submission_mail2.
- Fixed issue where attachments were not being saved.
Download this release
Release Info
Developer | jasongreen |
Plugin | Contact Form Submissions |
Version | 1.5.8 |
Comparing to | |
See all releases |
Code changes from version 1.5.7 to 1.5.8
- Submissions.php +125 -123
- contact-form-submissions.php +1 -1
- readme.txt +7 -1
Submissions.php
CHANGED
@@ -5,7 +5,7 @@ class WPCF7Submissions
|
|
5 |
{
|
6 |
add_action('init', array($this, 'post_type'));
|
7 |
|
8 |
-
add_action('
|
9 |
add_filter('wpcf7_posted_data', array($this, 'posted'), 999, 3);
|
10 |
}
|
11 |
|
@@ -72,132 +72,134 @@ class WPCF7Submissions
|
|
72 |
*
|
73 |
* @return [type] [description]
|
74 |
*/
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
137 |
|
138 |
/**
|
139 |
* Save the form submission into the db
|
140 |
*/
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
|
202 |
/**
|
203 |
* Get the path of where uploads go
|
5 |
{
|
6 |
add_action('init', array($this, 'post_type'));
|
7 |
|
8 |
+
add_action('wpcf7_mail_components', array($this, 'submission'), 999, 2);
|
9 |
add_filter('wpcf7_posted_data', array($this, 'posted'), 999, 3);
|
10 |
}
|
11 |
|
72 |
*
|
73 |
* @return [type] [description]
|
74 |
*/
|
75 |
+
public function submission($components, $contact_form)
|
76 |
+
{
|
77 |
+
global $wpcf7s_post_id, $wpcf7s_posted_data;
|
78 |
+
|
79 |
+
$contact_form_id = 0;
|
80 |
+
if (method_exists($contact_form, 'id')) {
|
81 |
+
$contact_form_id = $contact_form->id();
|
82 |
+
} elseif (property_exists($contact_form, 'id')) {
|
83 |
+
$contact_form_id = $contact_form->id;
|
84 |
+
}
|
85 |
+
|
86 |
+
// don't save mail2 autoresponders by default
|
87 |
+
if (!empty($wpcf7s_post_id) && false === apply_filters('wpcf7s_save_submission_mail2', false, $contact_form_id)) {
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
|
91 |
+
if (!empty($wpcf7s_posted_data)) {
|
92 |
+
foreach ($wpcf7s_posted_data as $name => $value) {
|
93 |
+
if ('_wpcf7' !== substr($name, 0, 6)) {
|
94 |
+
// skip empty arrays
|
95 |
+
if(is_array($value) && !array_filter($value)){
|
96 |
+
continue;
|
97 |
+
}
|
98 |
+
|
99 |
+
$fields[$name] = $value;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
$body = $components['body'];
|
105 |
+
$sender = wpcf7_strip_newline($components['sender']);
|
106 |
+
$recipient = wpcf7_strip_newline($components['recipient']);
|
107 |
+
$subject = wpcf7_strip_newline($components['subject']);
|
108 |
+
$headers = trim($components['additional_headers']);
|
109 |
+
|
110 |
+
// get the form file attachements
|
111 |
+
if ( $submission = WPCF7_Submission::get_instance() ) {
|
112 |
+
$attachments = $submission->uploaded_files();
|
113 |
+
}
|
114 |
+
|
115 |
+
$submission = array(
|
116 |
+
'form_id' => $contact_form_id,
|
117 |
+
'body' => $body,
|
118 |
+
'sender' => $sender,
|
119 |
+
'subject' => $subject,
|
120 |
+
'recipient' => $recipient,
|
121 |
+
'additional_headers' => $headers,
|
122 |
+
'attachments' => $attachments,
|
123 |
+
'fields' => $fields
|
124 |
+
);
|
125 |
+
|
126 |
+
if (!empty($wpcf7s_post_id)) {
|
127 |
+
$submission['parent'] = $wpcf7s_post_id;
|
128 |
+
}
|
129 |
+
|
130 |
+
// store the form submission
|
131 |
+
$post_id = $this->save($submission);
|
132 |
+
|
133 |
+
if (empty($wpcf7s_post_id)) {
|
134 |
+
$wpcf7s_post_id = $post_id;
|
135 |
+
}
|
136 |
+
|
137 |
+
return $components;
|
138 |
+
}
|
139 |
|
140 |
/**
|
141 |
* Save the form submission into the db
|
142 |
*/
|
143 |
+
private function save($submission = array())
|
144 |
+
{
|
145 |
+
if(true === apply_filters('wpcf7s_save_submission', true, $submission['form_id']))
|
146 |
+
{
|
147 |
+
$post = array(
|
148 |
+
'post_title' => ' ',
|
149 |
+
'post_content' => $submission['body'],
|
150 |
+
'post_status' => 'publish',
|
151 |
+
'post_type' => 'wpcf7s',
|
152 |
+
);
|
153 |
+
|
154 |
+
if (isset($submission['parent'])) {
|
155 |
+
$post['post_parent'] = $submission['parent'];
|
156 |
+
}
|
157 |
+
|
158 |
+
$post_id = wp_insert_post($post);
|
159 |
+
|
160 |
+
// check the post was created
|
161 |
+
if(!empty($post_id) && !is_wp_error($post_id)){
|
162 |
+
|
163 |
+
add_post_meta($post_id, 'form_id', $submission['form_id']);
|
164 |
+
add_post_meta($post_id, 'subject', $submission['subject']);
|
165 |
+
add_post_meta($post_id, 'sender', $submission['sender']);
|
166 |
+
add_post_meta($post_id, 'recipient', $submission['recipient']);
|
167 |
+
add_post_meta($post_id, 'additional_headers', $submission['additional_headers']);
|
168 |
+
|
169 |
+
$additional_fields = apply_filters('wpcf7s_submission_fields', $submission['fields'], $submission['form_id']);
|
170 |
+
if (!empty($additional_fields)) {
|
171 |
+
foreach ($additional_fields as $name => $value) {
|
172 |
+
if (!empty($value)) {
|
173 |
+
add_post_meta($post_id, 'wpcf7s_posted-' . $name, $value);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
$attachments = $submission['attachments'];
|
179 |
+
if (!empty($attachments)) {
|
180 |
+
|
181 |
+
$wpcf7s_dir = $this->get_wpcf7s_dir();
|
182 |
+
// add a sub directory of the submission post id
|
183 |
+
$wpcf7s_dir .= '/' . $post_id;
|
184 |
+
|
185 |
+
mkdir($wpcf7s_dir, 0755, true);
|
186 |
+
|
187 |
+
foreach ($attachments as $name => $file_path) {
|
188 |
+
if (!empty($file_path)) {
|
189 |
+
// get the file name
|
190 |
+
$file_name = basename($file_path);
|
191 |
+
|
192 |
+
$copied = copy($file_path, $wpcf7s_dir . '/' . $file_name);
|
193 |
+
|
194 |
+
add_post_meta($post_id, 'wpcf7s_file-' . $name, $file_name, false);
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
return $post_id;
|
201 |
+
}
|
202 |
+
}
|
203 |
|
204 |
/**
|
205 |
* Get the path of where uploads go
|
contact-form-submissions.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: Contact Form Submissions
|
4 |
Description: Never miss an enquiry again! Save all Contact Form 7 submissions in your database.
|
5 |
-
Version: 1.5.
|
6 |
Author: Jason Green
|
7 |
License: GPLv3
|
8 |
Domain Path: /languages
|
2 |
/*
|
3 |
Plugin Name: Contact Form Submissions
|
4 |
Description: Never miss an enquiry again! Save all Contact Form 7 submissions in your database.
|
5 |
+
Version: 1.5.8
|
6 |
Author: Jason Green
|
7 |
License: GPLv3
|
8 |
Domain Path: /languages
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: contact form 7, save contact form, submissions, contact form db, cf7, wpcf
|
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNHXWSXSPYATE
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.8.1
|
7 |
-
Stable tag: 1.5.
|
8 |
License: GPLv3
|
9 |
|
10 |
Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
|
@@ -19,6 +19,8 @@ Files are stored in the /wp-content/uploads directory and can be previewed or do
|
|
19 |
|
20 |
All submissions can be exported in CSV format using the export button.
|
21 |
|
|
|
|
|
22 |
This plugin has been made with no ads or donation links so you can use this on all your sites.
|
23 |
|
24 |
== Installation ==
|
@@ -40,6 +42,10 @@ None yet
|
|
40 |
|
41 |
== Changelog ==
|
42 |
|
|
|
|
|
|
|
|
|
43 |
= 1.5.7 =
|
44 |
* Fixed an issue where some admins were not able to export submissions.
|
45 |
* Now saves submissions when demo mode is enabled.
|
4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNHXWSXSPYATE
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.8.1
|
7 |
+
Stable tag: 1.5.8
|
8 |
License: GPLv3
|
9 |
|
10 |
Never miss an enquiry again! Save & Export your Contact Form 7 submissions.
|
19 |
|
20 |
All submissions can be exported in CSV format using the export button.
|
21 |
|
22 |
+
Please note this plugin will not work with demo mode enabled.
|
23 |
+
|
24 |
This plugin has been made with no ads or donation links so you can use this on all your sites.
|
25 |
|
26 |
== Installation ==
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 1.5.8 =
|
46 |
+
* Disabled saving mail2 by default. Overridable with filter wpcf7s_save_submission_mail2.
|
47 |
+
* Fixed issue where attachments were not being saved.
|
48 |
+
|
49 |
= 1.5.7 =
|
50 |
* Fixed an issue where some admins were not able to export submissions.
|
51 |
* Now saves submissions when demo mode is enabled.
|