• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Custom function on succesful login

#1
I'm trying to create addon which allow me to execute custom function on succesfull login. I'm stuck, little bit help please.

I have code event listener -> load_class_controller
PHP:
<?php

class Dev_Listener_LoadClassController
{
    public static function extendMemberController($class, array &$extend)
    {
        if ($class == 'XenForo_ControllerPublic_Login')
        {
            $extend[] = 'Dev_ControllerPublic_Login';
        }
    }
}
PHP:
<?php

class Dev_ControllerPublic_Login extends XFCP_Dev_ControllerPublic_Login
{
    public function actionIndex()
    {
        if ($login) {
           // Just for test
           file_get_contents('http://www.example.com/');
        }
    }
}
 

Nobita.Kun

Well-known member
#2
PHP:
class Dev_ControllerPublic_Login extends XFCP_Dev_ControllerPublic_Login
{
    public function actionLogin()
    {
        $response = parent::actionLogin();
       
        $visitor = XenForo_Visitor::getInstance();
        if ($visitor['user_id'])
        {
            // your code here when user login success!
        }
    }
}
Maybe this helpful for you
 
#5
UNsuccesfull login i get this:
Code:
No controller response from XenForo_ControllerPublic_Login::actionLogin

    XenForo_FrontController->_handleControllerResponse() in XenForo/FrontController.php at line 355
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    XenForo_FrontController->run() in /var/www/xenforo/index.php at line 13
And succesfull login i get this:
Code:
Security error occurred. Please press back, refresh the page, and try again.
 

Nobita.Kun

Well-known member
#6
Yep! You should return $response after your code reached!
Code:
public function actionLogin()
    {
        $response = parent::actionLogin();
      
        $visitor = XenForo_Visitor::getInstance();
        if ($visitor['user_id'])
        {
            // your code here when user login success!
        }
return $response;
    }