More fixes

WordPress: "Plugin could not be activated because it triggered a fatal error"

You clicked Activate and WordPress refused, with a red box and a line of PHP underneath. The good news: WordPress caught the crash before it switched the plugin on, so your site is still running exactly as before. The line under the message tells you why the plugin crashed. Here is how to read it, and the fix for each case.

What the owner sees

harborbakery.example/wp-admin/plugins.php

What the checks found


  

Find out which case it is (five minutes)

  1. Read the line under the message. It usually starts with Fatal error: or Parse error: and names a file and a line. If it is blank, add define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); to wp-config.php, click Activate again, and read wp-content/debug.log.
  2. Look for "Cannot redeclare" or "already declared". Two copies of the same code are loading: an old and a new copy of the plugin, a free and a Pro version, or a theme that bundles the same library.
  3. Look for "syntax error, unexpected" or "requires PHP". The plugin needs a newer PHP than your server runs. Tools, Site Health, Info, Server shows your PHP version; the plugin page on wordpress.org shows what it needs.
  4. Look for "Call to undefined function" or "Class not found". Either a PHP extension is missing on the server (mbstring, intl, zip, gd, curl) or the plugin is an add-on that needs its parent plugin active first.
  5. Look for "Allowed memory size exhausted". The plugin needs more PHP memory than the server gives.

The fixes, by case

  1. Cannot redeclare / already declared: deactivate and delete the other copy first (the free version before installing Pro, or an old folder such as plugin-name-1 left by a failed update), then activate. If the clash names your theme, ask the theme or plugin author which one should drop the bundled library.
  2. Syntax error or "requires PHP 8.x": raise the PHP version in your hosting panel (most hosts have a one-click PHP selector). Test on a staging copy first if your other plugins are old. Or install the last plugin version that supports your PHP.
  3. Missing PHP extension: enable it in the hosting panel's PHP extensions list, or send your host a one-line ticket naming the extension from the error.
  4. Undefined function from a parent plugin: add-ons for WooCommerce, Elementor, ACF and the like need the parent installed and active first. Activate the parent, then the add-on.
  5. Memory exhausted: add define('WP_MEMORY_LIMIT', '256M'); to wp-config.php; if the host caps it lower, ask them to raise memory_limit.
  6. Incomplete upload: a "failed to open stream" or "No such file" error points at a file that is not there. Delete the plugin and install it again from Plugins, Add New, or upload a fresh zip.
  7. A nulled or "free premium" copy: delete it. These are a common source of crashes and of hidden malware. Get the plugin from its author.

What you see, what it means, what it needs

What you seeWhat it meansUsual fix
Cannot redeclare ... / already declaredTwo copies of the same codeDelete the old or free copy, then activate
syntax error, unexpected ... / requires PHPServer PHP is too old for the pluginRaise PHP in the hosting panel
Call to undefined function mb_...A PHP extension is missingEnable the extension or ask the host
Class "WooCommerce" not foundAdd-on activated before its parentActivate the parent plugin first
Allowed memory size exhaustedPHP memory limit too lowWP_MEMORY_LIMIT 256M or host raises it
failed to open stream: No such fileThe upload was incompleteDelete and reinstall the plugin

What not to do

Most cases are one duplicate copy or one PHP setting. If the plugin still will not activate, that is what the box below is for. Related: "There has been a critical error", Memory exhausted, Outdated PHP, "Plugin does not have a valid header".