Front end login form not working on live site

Question

I am using the front end form submission. It works on localhost perfectly, but it’s not working when my site is live. It shows the “success message”, but originally it’s not logged in. This is my code:

if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' ) :    
    global $error;
    $login = wp_login( $_POST['user-name'], $_POST['password'] );
    $login = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'], 'remember' => $_POST['remember-me'] ), false );

    if (!$error) {
        save_message( 'success', __( 'You have successfully Login.', 'frontendprofile' ) );
        unset($_POST);
        wp_redirect( get_permalink( 4 ) );  
    }
    // wp_redirect( home_url() );
endif;

So what can I do to fix this?

0
Adi 6 months 0 Answers 78 views 0

Leave an answer