2016-11-22 57 views
1

我已經成功實現了onUserAuthenticate事件來實現我的自定義身份驗證API在Joomla!我正在努力的網站。Joomla! 3.xx * onUserLogout *事件不起作用

現在我想要在onUserLogout事件上運行一些自定義代碼。

我已將以下代碼添加到自定義身份驗證插件文件。 但是這種方法沒有被觸發/調用,而前一個(onUserAuthenticate)工作得很好。

/** 
* Method to handle the SSO logout 
* 
* @param array $user  Holds the user data. 
* @param array $options Array holding options (client, ...). 
* 
* @return boolean Always returns true. 
* 
* @since 1.6 
*/ 
public function onUserLogout($user, $options = array()) { 
    if (JFactory::getApplication()->isSite()) { 
     // Set the cookie to expired date. 
     setcookie('customAuth', '123', time() - (60 * 60 * 24 * 365), '/', '.customdomain.org'); 
    } 
    return true; 
} 

回答

1

好吧,我弄錯了。

所以我在處理onUserAuthenticate的同一個插件文件中加入了上述方法。

對於Joomla!登錄是一個單獨的過程,它有各自的事件,如onUserAuthenticate

但似乎事件onUserLogout必須在插件typeuser

因此,我在user插件類型目錄內創建了一個單獨的插件,並安裝了它並啓用了它....並且瞧!有效。

這讓我撓了一下頭。