If you were trying something new on your WordPress website and after editing/entering custom code on the settings page of the plugin My Custom Functions your website becomes inaccessible, you may decide to delete the plugin manually (via FTP) and install it again, but then you will run into the fact that the plugin could not be activated because it triggered a fatal error. In this article I will show you how to activate the plugin without errors and fix the error in your custom code that you entered on the plugin settings page.
If you are using the “Custom Code Manager” plugin instead, please read my other article here.
What causes this error
The My Custom Functions plugin has a built-in functions for checking the custom PHP code for syntax errors, duplicate functions names, and etc. But plugin is not perfect, so there are times when the entered custom code causes the error and white screen (WSOD). This is due to the fact that the custom PHP code that user entered on the plugin settings page has a syntax error that the plugin could not detect.
Did you recently paste a snippet from the web or updated an existing snippet? Then chances are you know exactly where to look. Most likely the problem is a syntax error. The syntax error is usually caused by a tiny but crucial mistake in your custom PHP code syntax. A missing comma, or an extra curly bracket can break the entire site. Due to this mistake, you now getting a white screen (WSOD) and the following error message (an example):
Plugin could not be activated because it triggered a fatal error. Parse error: syntax error, unexpected '}' in /wp-content/plugins/my-custom-functions/inc/php/functional.php(85) : eval()'d code on line 12
In the example of the error message above, it is reported that the plugin can not be activated due to an error. It indicates a syntax error (an extra symbol
}) on line 12 of the custom PHP code that user entered on the plugin settings page.
How to solve it
To solve this problem all you need to do is fix your custom PHP code that you entered on the plugin settings page before the crash. Despite the fact that the website does not respond and you can not get into the Admin Area, you can still edit your custom PHP code. For this, please perform the following steps.
- Access your server via FTP or SFTP.
If you aren’t sure how usually your web hosting provider will have instructions somewhere on their website.
- Browse to the directory
The location of the folder
wp-contentdepends on your host’s setup. Typically, the folder
public_htmlcontains all the files of the website, among which you will find this folder. Please contact your web hosting company to get help if you can’t find this folder.
- Rename the file
STOP. This will stop the execution of your custom PHP code that is causing the error. Now your website should be returned to life and the WordPress Admin Area should be accessible.
- Log in to Admin Area of your WordPress website.
- Go to the
- Find the plugin in the list of installed plugins and click the
Activatebutton below. Now the plugin should activate without errors.
- Go to the plugin settings page
- Edit/fix your custom PHP code that you entered before the crash.
- Return to the plugin folder and rename the file
That’s it, you’re done. You’re now have the plugin activated without errors. So simple isn’t it?
We are already working on a feature to automatically stop the execution of users custom PHP code for cases when this plugin could not detect the error, and this caused the inaccessibility of the website.
If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!
If this article has helped you solve the problem then please leave a comment
Thanks for reading!