title: Wordpress - Custom Change Password page
body: <p>I'm trying to create custom page for Change Password under Profile. When I store/update the new user password(already change to hash value), it will logout automatically. The new password can be use to login again. Is there any way to update user password without logout afterward? I would like to avoid using plugin...Below are my code:-</p>
  
  <pre><code>&lt;form method='post' action='changepassword'&gt;
  &lt;div class='mypageMyDetailsBox'&gt;
  &lt;span class='titleSub'&gt;Password&lt;/span&gt;
  &lt;table width='90%' align="center"&gt;
  &lt;tr&gt;
  &lt;td width='40%'&gt;Current Password&lt;/td&gt;
  &lt;td width='60%'&gt;&lt;input type='text' name='currentpassword' size='70'&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;New Password&lt;/td&gt;
  &lt;td&gt;&lt;input type='text' name='newpassword' size='70'&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;Confirm New Password&lt;/td&gt;
  &lt;td&gt;&lt;input type='text' name='confirmpassword' size='70'&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;div align='center'&gt;
  &lt;input type='submit' name='submit_update' value='Update' class='subUpt'&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;?php 
  if (isset($_POST['submit_update'])) {
  
  $currentpassword = $_POST['currentpassword'];
  $newpassword = $_POST['newpassword'];
  
  require_once ABSPATH . 'wp-includes/class-phpass.php';
  $wp_hasher = new PasswordHash( 8, true );
  
  $user_info = get_userdata($currentUserID); 
  $user_pass = $user_info-&gt;user_pass;
  
  if($wp_hasher-&gt;CheckPassword($currentpassword, $user_pass)) {
      $passhash = wp_hash_password($newpassword);
      $upd = $wpdb-&gt;query("UPDATE wp_users SET user_pass = '".$passhash."' WHERE ID = ".$currentUserID." LIMIT 1");
      if ($upd) {        
          //Success
      }
  } else {
      //Password not match 
  }
  }
  ?&gt;
  </code></pre>
  
  <p>Thank you in advance.</p>