I am trying to make a custom login page with registration and login on the same page with some custom fields so I didn't use any plugins. I wrote the following once the username and password are matched from the database.
$user_login=isset($get_user->user_login)?($get_user->user_login==''?'admin':$get_user->user_login):'admin'; $user=get_user_by('login',$get_user->user_login); do_action('wp_login', $get_user->user_login, $user); wp_set_current_user( $user->ID ); wp_set_auth_cookie( $user->ID );
Under that code I quickly did a var_dump($current_user) and I am able to verify that I am logged in and have everything working but once I refresh the page or navigate to other pages I lose the login. Is it something to do with my session or cookie settings? Has anyone encountered this problem?