mm-forms.php PHP7 Fix
If you’re using the MM-Forms WordPress plugin and PHP7, you’ll run into following Fatal Error message that can screw up your WordPress blog completely. For instance in my case, all pages didn’t work anymore and didn’t show any content.
Error Message:
[php7:warn] PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /is/htdocs/wp-content/plugins/mm-forms/mm-forms.php on line 114
Unfortunately the MM-Forms plugin doesn’t seem to be updated anymore, even the author’s website is dead. So we cannot expect any official bugfix.
Since I rely on this plugin and I didn’t have time to put any research into alternatives, I fixed it myself.
How to fix the MM-Forms PHP7 Error
1. Go to /wp-content/plugins/mm-forms/ and open the file mm-forms.php in any text editor (Notepad)
2. Go to line 114 and search for:
$pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "
", "\\0")', $pee);
3. Replace this line with:
$pee = preg_replace_callback(
'/<(script|style).*?<\/\\1>/s',
function($matches){
foreach($matches as $match){
return str_replace("\n", "
", $match);
}
},
$pee
);
4. Re-upload the fixed file.
Tested on Version 0.9.4b but should also work on earlier versions.
Or you can just download the file here: Download MM-Forms Fix
Please let me know in the comments if it worked for you.