• Hello, I am getting this problem

    Warning: Cannot modify header information – headers already sent by (output started at D:\wamp\www\Sunil\wordpress2testing\wordpress-3.3.1\wordpress\wp-includes\post-template.php:924) in D:\wamp\www\Sunil\wordpress2testing\wordpress-3.3.1\wordpress\wp-includes\pluggable.php on line 669

    Warning: Cannot modify header information – headers already sent by (output started at D:\wamp\www\Sunil\wordpress2testing\wordpress-3.3.1\wordpress\wp-includes\post-template.php:924) in D:\wamp\www\Sunil\wordpress2testing\wordpress-3.3.1\wordpress\wp-includes\pluggable.php on line 670

    I have done all the things like white spaces <?php ?> after the tag. and i also search in the forum to sort out the problem. but i did not get any solution.please help me out and check my code below if there is any problem with my code.

    It seems that i am getting the problem bcz of i am using the function wp_signon()….it works fine for only when username or password is wrong but when the username and password is correct then is throws error.

    Thanks in advance.
    avin.

    <?php
    if(is_user_logged_in())
    {
    //wp_redirect(home_url());
    echo “hello”;
    }
    else
    {
    if($_POST)
    {
    $username = $_REQUEST[‘log’];
    $password = $_REQUEST[‘pwd’];

    $creds = array();
    $creds[‘user_login’] = $username;
    $creds[‘user_password’] = $password;
    $creds[‘remember’] = true;
    $user = wp_signon( $creds, false );
    if ( is_wp_error($user) )
    {
    echo $user->get_error_message();
    }

    }
    else
    {
    echo ‘<form name=”login” method=”post” id=”wp_login_form” action=””/>’;
    echo ‘username’;
    echo ‘<input type=”text” name=”log” id=”log” />’;
    echo ‘password’;
    echo ‘<input type=”text” name=”pwd” id=”pwd” />’;
    echo ‘<input type=”submit” name=”submit” value=”log in”/>’;
    echo ‘</form>’;
    }

    }
    ?>

Viewing 1 replies (of 1 total)
  • If you add the wp_redirect part to an action callback, then it should work. So in your functions.php or somewhere you will need:

    add_action( 'pre_posts, 'am_login_redirect' );
    
    function am_login_redirect() {
        if( is_user_logged_in() ){
            wp_redirect( home_url() );
            exit;
        }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Warning: Cannot modify header information – headers already sent by (output star’ is closed to new replies.