@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.