2014-01-23 36 views
0

我已經創建了一個模板,通過它我正在爲用戶身份驗證運行查詢。問題出在用戶重定向到他/她的個人資料登錄按鈕後,仍然出現在菜單上。我想在地方登錄按鈕的退出按鈕,當用戶在和註銷後重定向到我的網站不WordPress的dashboard.Here的主頁登錄是代碼:從wordpress中的登錄表驗證用戶,並顯示註銷按鈕代替登錄按鈕?

<?php 
/** 
* Template Name: user-login 
* 
* Description: Twenty Twelve loves the no-sidebar look as much as 
* you do. Use this page template to remove the sidebar from any page. 
* 
* Tip: to remove the sidebar from all posts and pages simply remove 
* any active widgets from the Main Sidebar area, and the sidebar will 
* disappear everywhere. 
* 
* @package WordPress 
* @subpackage Twenty_Twelve 
* @since Twenty Twelve 1.0 
*/ 
get_header(); ?> 

<html> 
    <body> 
    <form method="post"> 
     <table align="center" cellspacing="10px"> 
     <tr> 
      <td><font size="+1">Username:</font></td> 
      <td><input type="text" name="uname1"></td> 
     </tr> 
     <tr> 
      <td><font size="+1">Password:</font></td> 
      <td><input type="password" name="upass1"></td> 
     </tr> 
     <tr> 
     <td><input type="submit" name="login" value="login"></td> 
     </tr> 
    </table> 

<?php 
    if(isset($_POST['login'])) 
    { 
     global $wpdb; 
     $name=$_POST['uname1']; 
     $pass=$_POST['upass1']; 

     $sql="select * from wp_member where username='".$name."' and  password='".$pass."'"; 
     $row=$wpdb->get_row($sql); 
     $id=$row->id; 
     if($row>0) 
     { 
     echo "<script>window.location.href='http://localhost/wordpress?page_id=387& id=$id'</script>"; 
     echo '<a href="'.wp_logout_url(get_permalink()).'" title="Logout"  class="hunderline">Logout</a>'; 
    } 

    else 
    { 
     echo "<div style='color: red'>Invalid User</div>"; 
    } 
    } 

?> 
</body> 

<?php 
    /*if (is_user_logged_in()) { } else { 
    echo '<a href="'.wp_login_url(get_permalink()).'" title="Login" class="hunderline">Login</a>'; 
    }*/ 
    get_footer(); 
?> 

回答