How to use logic Hook before_logout?

Hello all

I want to use logic hook (before_logout). how can i use it ? I want one confirmation box before logout i.e “you want to logout or not” if yes then “Logout” else “Not logout”.

Hi,

You add to the following file (create if it doesn’t exist and start with the <?php tag)
custom/modules/Users/logic_hooks.php

Add the following:

$hook_array['before_logout'] = Array();
$hook_array['before_logout'][] = Array(1, 'Logout Confirm box', 'custom/modules/Users/hook_functions.php','beforelogoutclass', 'beforelogoutmethod');

Add the file
custom/modules/Users/hook_functions.php

With contents

<?php
class beforelogoutclass {
    public static function beforelogoutmethod(&$bean, $event){
        if ($event == 'before_logout'){
            // do your stuff
        }
    }
}

In case you are packaging your change in a module, you’ll need this entry in manifest.php:

'logic_hooks' => array(
     array(
        'module'         => 'Users',
        'hook'           => 'before_logout',
        'order'          => 1,
        'description'    => 'Logout Confirm box',
        'file'           => 'custom/modules/Users/hook_functions.php',
        'class'          => 'beforelogoutclass',
        'function'       => 'beforelogoutmethod',
     ),

Thank you i will try to do that and let you know if face any issues.