I am trying to make a partner portal page (page for our business partners to see important information specific to them) and therefore wanted to create a custom login page.

I have read many tutorials online, and I am following the directions exactly but it is just not working.

I am making the login page by making a page template and putting it into my custom theme.

Here is the template code:

* Template Name: Log in

if($_POST) { 

global $wpdb; 

//We shall SQL escape all inputs 
$username = $wpdb->escape($_REQUEST['username']); 
$password = $wpdb->escape($_REQUEST['password']); 
$remember = $wpdb->escape($_REQUEST['rememberme']); 

if($remember) $remember = "true"; 
else $remember = "false"; 

$login_data = array(); 
$login_data['user_login'] = $username; 
$login_data['user_password'] = $password; 
$login_data['remember'] = $remember; 

$user_verify = wp_signon( $login_data, false );

if ( is_wp_error($user_verify) ) { 
    echo '<span class="mine">Invalid Login Details</span>'; 
} else { 
    echo "<script type='text/javascript'>window.location.href='". home_url() . '/partner-portal/' ."'</script>"; 
} else {  


<form id="wp_login_form" action="<?php echo home_url(); ?>/login/" 
<div><img src="this-is-an-image.png"/></div>
<label for="tab-1" class="tab">Sign In</label><br>

<label class="my-username" >Username</label><br> 
<input type="text" name="username" class="text" value=""><br> 
<label class="my-password" >Password</label><br>

<input type="password" name="password" class="text" value=""> <br> 
<input class="myremember" name="rememberme" type="checkbox" value="forever"> 
<span class="hey">Remember me</span></label> 
<input type="submit" id="submitbtn" name="submit" value="Login"> 
<?php get_footer(); ?>

Notes: When I enter incorrect credentials I get the "Invalid login details" as is expected.

When I enter correct credentials it redirects me to the /partner-portal/, however running a quick is_user_logged_in() shows me that the user is not logged in.

Any help would be appreciated!

  • First of all... Why do you run wpdb->escape on request data at the beginning? It makes no sense at all (password CAN contain ' character for example)... Dec 14, 2018 at 7:24

1 Answer 1


You need to set below code in else condition

wp_set_current_user($user_verify ->ID);
wp_set_auth_cookie($user_verify ->ID, true);

hope this will help you and let me know if this is help or not

  • That did not work for me either. It has the same issue as before. It will redirect to the next page, but it still says i'm not logged in. I found a temporary fix for now. Instead of using this completely custom login page I am just using wp_login_form() and customizing the design with javascript.
    – Kurisubo
    Dec 14, 2018 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.