As you can see, there are two files mentioned by the error. The first file (in our case: my-function.php located at /public_html//wp-content/plugins/my-plugin/) is the chief culprit of the error. This is our custom code that is used to override the core functionality provided by WordPress. The core functionality in question is in the pluggable.php file (a core WordPress file which is the same for every WordPress installation). Basically, there is a problem in the first file which is preventing the second file to function properly.
The major cause of this error are blank spaces present in the first file. These could be blank spaces at the top or bottom of the file, unnecessary blank spaces anywhere in the file or even blank spaces between the <?php and ?> PHP tags. In fact, because programmers can (and usually do) mistakenly type extra spaces when writing code, this error is more common than you’d expect. The line # indicated in the error message corresponds to where the problem is specifically originating – it will help you eradicate it without too much fuss.
Option 1 – Editing corrupted files
The first option when troubleshooting the Warning: cannot modify header information error is to manually edit the faulty file. You are already supplied with the necessary information to locate the problem in the error message (remember, it’s the first file in the message). All you need to do is open up this file, either through an FTP client like FileZilla, or through File Manager.
Essentially, all you’re looking to do here is to remove extra spaces present in the file. A good place to start would be the line # mentioned in the error message. From there, you can continue to parse the rest of the file and look for additional unneeded spaces/blanks until the end of the document.
Make sure to pay special attention to the starting and ending PHP tags. There should not be spaces before or after the <?php tag, as well as the ?> tag. Also, the last line of code should not be followed with a blank line or extra space.
Option 2 – Replace corrupted files
Of course, editing multiple corrupted files can be difficult. Files could belong to a plugin or theme you recently incorporated in your site, or could even be a core WordPress file.
If the error is indeed caused by a plugin or theme, all you need to do is re-install it. Doing this fixes the error in most cases. On the other hand, if a core WordPress file is the culprit of the error, your best bet is to get yourself a clean copy of WordPress and replace the corrupted file on your installation with the one present on the clean version. This will ensure that the corrupted file has been restored to its original state while keeping the rest of your WordPress installation intact. Now, simply reboot and make sure that the error is fixed.