How to Fix Pluggable.php Errors in WordPress

Pluggable.php Errors

Introduction

A pluggable.php error can look scary. A line of code text shows at the top of your page. Or you cannot log in at all. Sometimes the whole screen goes white. The good news is that your content is safe. In most cases, one small file causes the fault.

The message names a file called pluggable.php. That file is part of WordPress itself. It lives in the wp-includes folder. It holds core jobs such as logging in, sending mail and moving you to a new page. Here is the key point. This file is almost never the one that is broken. It is only the place where WordPress notices the problem.

These errors tend to appear after a change. You may have edited a theme file. You may have pasted in a code snippet. A plugin update or a new PHP version can also set them off. This guide shows you how to read the message. Then it covers each cause and a fix to match. You will also learn how to stop the error coming back.

Signs That Show Pluggable.php Errors on Your Site

The most common sign is a warning in plain text. It often reads “Cannot modify header information – headers already sent by”. After that comes a file path and a line number. The line ends with a mention of pluggable.php. The text may sit above your site header or inside the dashboard.

Other signs are less direct. You type your password and the login page just reloads. You save a post and land on a blank screen. A form submits, but the next page never opens. All of these happen because a redirect or a login cookie failed. If login is your only symptom, our guide to a WordPress login page that is not working covers the other causes.

Some sites show a fatal error instead. It may say “Call to undefined function wp_get_current_user()”. It may say “Cannot redeclare” and then a function name. In these cases the page stops part way. You may see the WordPress critical error screen in place of your site.

Check where the error shows. Is it on every page, or only in the dashboard? Does it show only when you log in or save? Write down the exact words too. Those details point you to the right step below. If you see a blank page with no text at all, read our white screen of death guide first.

Reasons Why Pluggable.php Errors Happen

Seven causes sit behind nearly every pluggable.php error. Each one breaks your site in its own way.

Blank Space Before or After the PHP Tags

A web page is sent in two parts. First come the headers. These are hidden notes for the browser, such as cookies and redirects. Then comes the page you can see. Headers must always go first. Once any part of the page is sent, the headers are locked. A single space or blank line outside the PHP tags counts as page output. So a stray space in wp-config.php or functions.php locks the headers too soon. Later, pluggable.php tries to set a login cookie and fails.

A Hidden BOM Mark at the Start of a File

Some text editors add three hidden bytes to the start of a file. This is called a byte order mark, or BOM. You cannot see it in most editors. PHP still sends it to the browser as output. The effect is the same as a stray space. The headers lock before WordPress is ready to send them. This often happens after you edit a file in a basic notepad app and upload it again.

PHP Notices Printed on the Screen

PHP can print notices and warnings onto the page. A notice is a small message about untidy or old code. It does not stop your site. But the printed text still counts as output. If it prints before the headers go out, they lock. This cause often shows up after a PHP version upgrade. Older plugins then set off new “Deprecated” notices. The site worked fine last week, and now each page shows a header warning.

A Plugin or Theme That Sends Output Too Early

Some code prints text at the wrong time. A snippet may use an echo line straight inside functions.php. A plugin may print a message while it loads. Both send output before WordPress has done its header work. The warning then shows on any page that redirects or sets a cookie. Pages that do neither may look fine, which makes this cause hard to spot. It is common right after you paste in a snippet from the web.

A Plugin That Calls a Function Too Early

WordPress loads its parts in a fixed order. It loads your active plugins first. Only then does it load pluggable.php. This order lets a plugin swap a pluggable function for its own. But it has a side effect. A plugin that asks “who is logged in?” while it loads has asked too soon. The function it needs does not exist yet. PHP stops with a “Call to undefined function” fatal error.

Two Copies of the Same Pluggable Function

A pluggable function can be replaced, but only once. Say two plugins each bring their own wp_mail function. PHP does not allow two functions with one name. The same clash happens when a theme defines one in functions.php. Themes load after pluggable.php, so the name is already taken. PHP stops with a “Cannot redeclare” fatal error. The message names both of the files that clash.

A Damaged or Missing Core File

Now and then, pluggable.php really is the broken file. A WordPress update can stop half way. An upload can cut a file short. An attack on your site can change core files. You may then see “Parse error” or “Failed to open stream” with pluggable.php as the only file named. No plugin or theme path shows in the message. This cause is rare, but the fix is simple.

How to Fix Pluggable.php Errors (Step by Step)

Start by reading the full error message. It often holds two file paths. The first comes after the words “output started at”. That is the file that caused the fault. The second is pluggable.php, where WordPress noticed it. Now work through the steps in order. They run from the simplest check to the deepest one. Take a full backup before you edit any file. Our guide shows how to back up WordPress with UpdraftPlus. If you cannot reach your dashboard, use your host’s File Manager or an FTP app.

Step 1: Remove Blank Space From the File Named in the Error

This step fixes the stray space cause. Any space outside the PHP tags goes to the browser as output. That locks the headers before WordPress can send a cookie or a redirect.

First, confirm that this is your cause. Look at the first path in your message. Say it reads “output started at /wp-content/themes/yourtheme/functions.php:1”. The number after the colon is the line. Line 1 points to the very top of the file. A number that matches the last line points to the bottom. Either result suggests stray space. A line in the middle of the file points to Step 4.

Download a copy of the file as a backup. Then open the file in your host’s File Manager. It must begin with <?php and nothing in front of it. Remove any space or blank line you find there. Now scroll to the end. If you see a closing ?> tag, delete it and all that follows it. A file that holds only PHP does not need that closing tag. Save the file.

Reload the page that showed the error. Try to log in or save a post. If the warning is gone, you are done. If the same file and line 1 still show, move on to Step 2.

Step 2: Save the File Again Without a BOM

This step fixes the hidden BOM cause. The BOM is sent as output just like a space. You cannot see it, so the file looks clean.

You can confirm it by ruling out Step 1. The error still names line 1 of the file. Yet nothing sits in front of the opening PHP tag. It is even more likely if you edited the file on your own computer and then uploaded it.

Download the file. Open it in a code editor such as Notepad++ or VS Code. In Notepad++, open the Encoding menu and choose “Convert to UTF-8”. Do not pick the option that ends in BOM. In VS Code, click the encoding label in the bottom bar. Choose “Save with Encoding”, then “UTF-8”. Save the file and upload it over the old one.

Reload the page and repeat the action that failed. A clean page means the BOM was the cause. If the path in the message now points to a new file, repeat Steps 1 and 2 for that file. If nothing changed, go to Step 3.

Step 3: Stop PHP Notices Printing on the Screen

This step fixes the printed notice cause. Each notice on the page is output. When one prints early, the headers lock and the pluggable.php warning follows.

Look at the top of the broken page. Do you see lines that start with “Notice”, “Warning” or “Deprecated” above the header warning? Does the “output started at” path sit inside a plugin or theme folder? Did the trouble start after a PHP upgrade? If so, this is your cause.

You will edit wp-config.php, and a slip there can take the site down. Download a copy of the file first. Then open it and find the line that says “That’s all, stop editing”. Add these lines just above it. If a WP_DEBUG line is already there, change it. Do not add a second one.

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

These lines tell WordPress to write messages to a log file. They no longer print on the page. The log is called debug.log and sits in the wp-content folder. The official WordPress debugging guide explains each setting. Open the log and note which plugin or theme the notices name. Update that plugin or theme. If no update exists, ask its author for one or swap it for a kept-up tool.

Reload the page. The header warning should be gone. When the log stays quiet, set WP_DEBUG back to false and delete the log file. If the warning stays and no notices show, go to Step 4.

Step 4: Find the Plugin or Theme That Sends Output Early

This step fixes code that prints at the wrong time. An early echo or a stray block of HTML locks the headers. The fault is in the plugin or theme, not in WordPress.

Check the “output started at” path again. Here it points inside a plugin or theme folder, and to a line in the middle of the file. No notices print above it. The error may also have begun right after you added a snippet or turned on a plugin.

If you added a snippet lately, remove it first. If the path sits in wp-content/plugins, go to the Plugins screen and deactivate that plugin. Locked out of the dashboard? Open File Manager and rename that plugin’s folder. Adding “-off” to the name is enough. WordPress then switches the plugin off by itself. If the path sits in your theme, open Appearance, then Themes. Activate a default theme such as Twenty Twenty-Five as a test. Our guide to finding a WordPress plugin conflict shows the full test method.

Reload the page and repeat the failed action. If the error is gone, you have found the source. Update that plugin or theme, or report the fault to its author. If the error stays, turn the item back on and go to Step 5.

Step 5: Fix a Function That Is Called Too Early

This step fixes the load order cause. A plugin has used a pluggable function while plugins were still loading. WordPress had not loaded pluggable.php yet, so the function was missing.

The wording gives this one away. The message says “Call to undefined function”. It then names a function such as wp_get_current_user(). The file path, or the trace lines under it, names a plugin folder. It often starts right after you activate or update that one plugin.

Rename the plugin’s folder in File Manager to switch it off. Your site should come back at once. Then check for a newer version of the plugin and install it. Rename the folder back and activate the plugin again. If the error returns, leave the plugin off and report the bug to its author. If the code is your own, move the call inside a hook. By the time the init hook runs, WordPress knows who the user is.

add_action( 'init', function () {
    $user = wp_get_current_user();
} );

Load your home page and your dashboard. Both should open with no fatal error. Then test the feature that the plugin adds. If you see a new message that says “Cannot redeclare”, go to Step 6.

Step 6: Remove the Duplicate Pluggable Function

This step fixes the name clash cause. Two pieces of code have defined one pluggable function. PHP refuses to load the second one and stops the page.

The message starts with “Cannot redeclare” and a function name. It goes on with “previously declared in” and a second file path. So you get both sides of the clash in one line. Note the two folders that the paths name.

If both paths point to plugins, the two plugins do the same job. Mail plugins are a common case, since each may replace wp_mail. Keep the one you need and deactivate the other. If one path is your theme’s functions.php, download a copy of that file first. Then remove the function from it. Code that replaces a pluggable function belongs in a plugin, not in a theme. It should also sit inside a check like this one.

if ( ! function_exists( 'wp_mail' ) ) {
    // your replacement function goes here
}

Reload the site. The fatal error should be gone on every page. Test the feature that the function controls, such as a contact form email. If mail then fails to arrive, see our guide on WordPress emails not sending.

Step 7: Replace Damaged WordPress Core Files

This step fixes a broken or missing core file. If pluggable.php is cut short or absent, WordPress cannot load its login and mail functions at all.

Check the message once more. It names pluggable.php alone, with “Parse error” or “Failed to open stream”. No plugin or theme path shows. The fault may have begun after a core update that did not finish. Our guide to a failed automated WordPress update explains how that happens.

Take a full backup of files and database first. If you can reach the dashboard, open Dashboard, then Updates. Click the button that installs your current version again. This replaces the core files only. It leaves your wp-content folder and wp-config.php alone. If you are locked out, download a fresh copy of WordPress from wordpress.org. Unzip it on your computer. Upload its wp-includes folder over the one on your server and choose to overwrite. Do not upload the wp-content folder. Never edit pluggable.php by hand, since the next update will wipe your change.

Load the site and log in. A clean load means the core file was the cause. If core files keep changing by themselves, scan the site for malware. If the error still shows after all seven steps, ask your host or a WordPress expert to read the server error log.

Best Practices to Prevent Pluggable.php Errors in Future

Most of these errors start with a small edit. So the first habit is to edit with care. Use a real code editor, not a basic notepad app. Save files as UTF-8 with no BOM. Leave the closing PHP tag off files that hold only PHP. That one habit removes the risk of stray space at the end of a file.

Keep your own code away from live theme files. Put snippets in a child theme or a small custom plugin. Test each change on a staging site first. The same care applies to small jobs, such as when you remove the Powered by WordPress footer link. Take a backup before every file edit, so you can roll back in a minute.

Keep error display turned off on your live site. Send messages to the log and read it now and then. Before a PHP upgrade, update every plugin and theme. Then test the new PHP version on staging. This stops a flood of fresh notices from locking your headers.

Use one plugin for each job. Two mail plugins or two login plugins may both try to replace the same pluggable function. Remove plugins that no longer get updates, since old code is more likely to call functions too early. Last, let core updates finish before you close the tab. Keep recent backups in case one does fail.

Conclusion

Pluggable.php errors show up as header warnings, failed logins, blank screens after saving, or fatal errors. The file named in the message is rarely the real fault. The true cause is nearly always stray space, a hidden BOM, printed PHP notices, early output, a function called too soon, a duplicate function or a damaged core file.

The fix starts with reading the message. The “output started at” path tells you which file to open. From there, clean the file, quiet the notices, or switch off the plugin at fault. Replace core files only when the message names pluggable.php alone. After each step, repeat the action that failed to confirm the result.

To keep the error away, edit files with a proper code editor and test on staging. Keep plugins, themes and PHP in step with each other. Back up before every change. With those habits, a pluggable.php error becomes a rare and quick fix. If you get stuck, our WordPress support team can trace the cause for you.