I have the exact same problem here.
Does anyone have an answer to this?
Me, three.
I’m seeing this in my logs:
Feb 3 21:31:51 PHP Warning: Invalid argument supplied for foreach() in /…/wp-content/plugins/cforms2/lib_nonajax.php on line 478
cformsII: 14.8
Ajax: Disabled
The error shows up in the logs. Like codifex, the message is sent successfully.
Même problème.
Si j’active Ajax l’email semble être envoyé mais n’arrive jamais.
This should be fixed in 14.8.1
Plugin Contributor
codifex
(@codifex)
I updated to 14.8.1 but I still see this error, however, the line number changed to 480:
Warning: Invalid argument supplied for foreach() in [...]/wp-content/plugins/cforms2/lib_nonajax.php on line 480
Thank you for your effort!
Just as codifex, I still see the error in 14.8.1. Also have line 480 now.
Thankful for any help.
I fixed mine by going to the file “lib_nonajax.php” making a duplicate of it and then deleting the following from the original copy of that file… Until I have heard back from the developers on this error, I am happy with my fix.
### form w/ files, within session or single form
if ( $doAttach && $ongoingSession!=’0′ && is_array($file) ){
foreach( $file[tmp_name] as $fn ){
cforms2_base64($fn, $doAttach);
### debug
cforms2_dbg( “File = $fn, attach = $doAttach” );
}
}
### end of session w/ files
if( $ongoingSession==’0′ && is_array($_SESSION[‘cforms’][‘upload’]) ){
foreach ( array_keys($_SESSION[‘cforms’][‘upload’]) as $n ) {
foreach ( array_keys($_SESSION[‘cforms’][‘upload’][$n][‘files’]) as $m ){
cforms2_base64(str_replace(‘xx’,$subID,$_SESSION[‘cforms’][‘upload’][$n][‘files’][$m]), $_SESSION[‘cforms’][‘upload’][$n][‘doAttach’] );
### debug
cforms2_dbg( “(end of session) File = “.$_SESSION[‘cforms’][‘upload’][$n][‘files’][$m].”, attach = “.$_SESSION[‘cforms’][‘upload’][$n][‘doAttach’] );
}
}
}
Thanks mooshmedia! Worked well for me.
…but that was a mistake. The solution from mooshmedia indeed worked well for the forms with no file attachment. But the forms where I use file attachments did not work.
So I decided to take that “fix” away. I’ve also discovered that the original error only shows up in the forms where I don’t use file attachments. Could that help us out with a proper solution?
Plugin Contributor
codifex
(@codifex)
I investigated the issue and I found out that the problem is caused by $file being an empty array on line 480 in “lib_nonajax.php”.
Proposed fix:
Add the check described above to line 479 by changing
if ( $doAttach && $ongoingSession!='0' && is_array($file) ){
to
if ( $doAttach && $ongoingSession!='0' && is_array($file) && !empty($file) ){
This seems to fix the problem.
codifex, thank you for the patch. I will include it in the next version.