2011-04-25 105 views
0

我在/views/wp_users/login.php中有一個表單,要求輸入登錄信息。但是現在,因爲我正在閱讀來自Cookie的登錄信息,所以我需要刪除表單。但我不知道如何使它的是,當用戶來爲localhost/WordPress的/ MYAPP/wp_users他們重定向到索引頁面,而不是登錄當人登錄時需要登錄腳本

這裏是我的控制器

編輯:

剛改變了登錄的功能,它的工作原理。

回答

2

您需要修改login動作和手動加載數據到驗證組件

function login() { 
    if (DO_COOKIE_CHECK) { 
     //read cookie data. If user is verified load up the user data and set it with 
     // the Auth Components login method 
     $this->data = $this->User->read(null, $idFromCookie); 
     $this->Auth->login($this->data); 
     // redirect user to index.php 
    } 
    //rest of code 
} 
+0

我amnew到cake..can你解釋這一點。 $ this-> data = $ this-> User-> read(null,$ idFromCookie);我必須有身份證嗎?它從哪裏來?我沒有cookie中的ID – Autolycus 2011-04-25 04:39:45

+0

您需要在cookie中擁有用戶標識或用戶名。否則,你將不知道要加載哪個用戶。一旦你有了標識符,加載用戶記錄,並將其傳遞給Auth組件以自動登錄 – JohnP 2011-04-25 04:56:07

+0

是的,我沒有意識到$ this-> User-> read(null,$ idFromCookie);實際上將數據發送到模型。謝謝 – Autolycus 2011-04-25 05:05:09