Warning: Cannot modify header information when using require or require_once (1 post)

  1. Samuel
    Posted 3 years ago #

    Hi, I'm WordPress newbie.

    I'm creating a plugin that redirect to custom login page each unregistered user access a website, let say the custom login page : custom_login.php.

    I am able to create a code to redirect it but it seems no wordpress functions work in custom_login.php. So, I think I have to load something through the file. I guess wp-load.php.

    Then I add some codes below at the top of the page :

    require( 'd:\xampp\htdocs\wordpress\wp-load.php' );

    But then I got this error :
    Warning: Cannot modify header information.....

    I changed to require_once but still get similar error.

    Some solutions of this forum threads advice to delete any whitespace. Frankly, I don't know what does it mean but I tried to delete all whitespace anyway so that the code become :

    <?php require('d:\xampp\htdocs\wordpress\wp-load.php');?>

    But it does not solve anything. The error is still exist.

    Please help me, the expert ones.
    Thanks in advance

Topic Closed

This topic has been closed to new replies.

About this Topic