Is it possible to do such a thing?

    if ( !is_user_logged_in() ) { ?>
    <!-- Users not logged in -->
        <form id="wp_login_form" action="" method="post">
            <label class="my-username" >Username o Email</label>
            <input type="text" name="username" class="info-login" value="" placeholder="example@gmail.com">
            <label class="my-password" >Password</label>
            <input type="password" name="password" class="info-login" value="" placeholder="******">
            <input class="myremember" name="rememberme" type="checkbox" value="forever"><span class="hey">Remember me</span>
            <button type="submit" id="submitbtn" name="submit" value="Login">Login</button>
        } else {
            // Users logged in
            wp_redirect( home_url() . '/dashboard' ); 

Because if it were possible when I do, the logged in users are not redirected and receive this error instead of the form:

Warning: Cannot modify header information - headers already sent by ....

And since I see this error several times, can you explain what it means?

Thanks a lot.


I solved by adding the following code before get_header ();

if ( is_user_logged_in() ) {
    wp_redirect( home_url() . '/dashboard' ); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.