After_logout logic hook error

Hi All,

I am facing after_logout logic hook issue in suite crm .

Kindly help

Thanks
Jyoti

the error is telling you what the problem is, did you check the number of parameters?

It would help if you posted the entire hook file so we can look at the code…

Hello,

Thanks for reply

crm_/custom/modules/Logout_Hook.php (code)-

<?php
    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    class logout_class
    {
       function after_logout_method($bean, $event, $arguments)
        {
            global $db;
            global $current_user; 

            //generic code to save detail of logged in user in User Activity module
            if ($bean->module_name != 'jj_User_Activity'  && $bean->module_name !='UserPreferences')
            {
                $leadsBean = BeanFactory::getBean('jj_User_Activity');
                $leadsBean->name = $bean->name;
                $leadsBean->action_c = 'Logout';
                $leadsBean->related_module_c = $bean->module_name;
                $leadsBean->assigned_user_id = $current_user->id;
                $leadsBean->save();
            }
        }
    }
?>

And the second file is - crm_/custom/Extension/application/Ext/LogicHooks/user_activity_tracking.php

$hook_version = 1; 
$hook_array = Array(); 
 

$hook_array['after_logout'] = Array();
$hook_array['after_logout'][] = Array(1,'after_logout example','custom/modules/Logout_Hook.php','logout_class','after_logout_method');



please help

Those two files don’t match - one if for login, the other for logout. I’m trying to check for minor details, we need to be precise here…

In the hook declaration, you’re not including $hook_array['after_logout'] = Array();, it would normally look like this:

<?php

$hook_version = 1; 
$hook_array = Array(); 
$hook_array['after_login'] = Array();
$hook_array['after_login'][] = Array(1,'after_login example','custom/modules/Login_Hook.php','logic_hooks_class','after_login_method');

The difference would be - clearing out the array before adding your hook. This way you would be sure you’re not constantly adding more and more hooks.

Sorry for that

$hook_version = 1;

$hook_array = Array();

$hook_array[‘after_logout’] = Array();

$hook_array[‘after_logout’][] = Array(1,‘after_logout example’,‘custom/modules/Logout_Hook.php’,‘logout_class’,‘after_logout_method’);

i added wrong code by mistake . i checked with above code but it is not working.

What is your version of SuiteCRM?

its ‘suitecrm_version’ => ‘7.11.4’,

Ok, so this matches what you have in your file at that same line number?

I am trying to check what your call stack says in the error message you pasted.

My interpretation of this is that login and logout logic hooks don’t have an associated bean, so their signature should really be just this:

       function after_logout_method($event, $arguments)

Of course, then you won’t have a $bean variable to reference in your code. But which bean were you expecting to get from that argument? A logout is not an action related to a bean…

Just to add - I var_dumped variables in the after_login function and it is actually:

function after_logout_method(&$bean, $event)