How to Fix Cherry Framework’s create_function PHP Fatal Error.

Hey there! It’s been a while since I’ve encountered a Cherry Framework error of any sort—the last being a ‘‘continue’ not in the ‘loop’ or ‘switch’ context error.

And while Cherry Framework has work seamless since then, I recently discovered that upgrading to the latest PHP version introduced yet another dreaded PHP Fatal error of “Call to undefined function create_function().”

If you’ve encountered this error too while using the Cherry Framework, don’t worry, I’ve got you covered with a fix, so you can get your website back up and running smoothly.

So, here’s the issue: the function “create_function()” used in the Cherry Framework is deprecated in newer versions of PHP, leading to this fatal error.

One fix would be to go backward in PHP versions. Still, the challenge with this is that it opens your website up to extreme security vulnerabilities and hacking exploits that could lead to other bad things happening that we won’t mention. 😳

But fret not, the solution I’m providing you with is quite simple. We must modify some code to ensure compatibility with the latest PHP versions.

First things first, let’s locate the problematic code. You’ll find it in the functions.php file of your Cherry Framework theme. The error message specifies that it occurs on line 272 or somewhere before or after this line, so that’s where we need to focus.

The code you need to change is:

<?PHP

add_filter('login_errors', create_function('$a', "return null;"));

?>

To fix it, we’ll replace it with the following code:

<?PHP

add_filter('login_errors', function($a){ return null; });

?>

By making this modification, we’re replacing the deprecated create_function with an anonymous function, which is recommended in newer PHP versions.

Once you’ve made this change, save the file, and you should be good to go! The PHP Fatal error should no longer be haunting your website.

I hope this tutorial has been helpful in resolving the Cherry Framework’s create_function PHP Fatal Error.

If you have any questions or need further assistance, please comment below.

Happy coding!

Share:
Written by Alvin Brown
He's an experienced and passionate serial entrepreneur, founder and publisher of Kickstart Commerce. Alvin possesses a great love for startups dominating their market using profitable digital strategies for greater commerce.