Open CraigT543 opened 7 years ago
It looks like the problem is in CF7DBPlugin.php and the use of posted_data which is depreciated since 3.9. In CF7 documentation I found:
` / WPCF7_ContactForm object no longer has a posted_data property. / $posted_data = $contact_form->posted_data; // Wrong.
/ Use WPCF7_Submission object's get_posted_data() method to get it. / $submission = WPCF7_Submission::get_instance();
if ( $submission ) { $posted_data = $submission->get_posted_data(); }
`
My at least temporary solution:
In CF7DBPlugin.php after line 794 ($user = null;) I have added the following:
`
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
}
$user = $posted_data['userlogin'];
` And within my forms I have added the following hidden field near the bottom of the forms:
[hidden userlogin default:user_login]
This restores the functioning of the program for now. I am sure there is a better way.
The better more permanent solution:
In your contact form add the following near the bottom of the form:
[hidden userlogin default:user_login]`
And within your Functions.php add the following:
`//Add Submitted Login to CF7 forms where [hidden userlogin default:user_login]
function filter_add_cf7_submitted_login($formData) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
$formData->user = $posted_data['userlogin']; // string user name if submitter was logged in. May be null
}
return $formData;
}
add_filter('cfdb_form_data', 'filter_add_cf7_submitted_login');
The submitted login field for logged in users will not post when using CF7 4.8. It works fine if we roll back to CF7 4.7.