SocialEngine hook does not work

63 Views Asked by At

I have created a new module to add a new step to the signup process to get the user's phone number. Everything works fine, except the fact that after the signup, I need to grab the phone number I have received in my specific step and add it to the users table. For this purpose, I have added a hook in my module's manifest file as follows to be triggered after signup completes:

<?php

return array(
    'package' =>
    array(
        'type' => 'module',
        'name' => 'advancedsmsplugin',
        'version' => '4.0.0',
        'sku' => 'com.company.sms',
        'path' => 'application/modules/Advancedsmsplugin',
        'title' => 'Advanced SMS Plugin',
        'description' => 'Advanced SMS Plugin',
        'author' => 'Company Ltd.',
        'callback' =>
        array(
            'class' => 'Engine_Package_Installer_Module',
        ),
        'actions' =>
        array(
            0 => 'install',
            1 => 'upgrade',
            2 => 'refresh',
            3 => 'enable',
            4 => 'disable',
        ),
        'directories' =>
        array(
            0 => 'application/modules/Advancedsmsplugin',
        ),
        'files' =>
        array(
            0 => 'application/languages/en/advancedsmsplugin.csv',
            1 => 'application/modules/User/Form/Signup/Phone.php',
            2 => 'application/modules/User/Plugin/Signup/Phone.php',
        ),
    ),
    'hooks' => array(
        array(
            'event' => 'onUserCreateAfter',
            'resource' => 'User_Plugin_Phone',
        ),
    ),
);
?>

I have also created the class that I named in the hook namely User_Plugin_Phone and saved it as application/modules/user/Plugin/Phone.php.

class User_Plugin_Phone  extends Core_Plugin_Abstract {

    public function onUserCreateAfter($event) {
        echo '<script>console.log("Inside User_Plugin_Phone::onUserCreateAfter");</script>';

        echo '<script>alert("Inside User_Plugin_Phone: onUserCreateAfter");</script>';

        $payload = $event->getPayload();
    }

}

But, logs show that the hook is not triggered at all. I have checked this and this, and I think I have followed them correctly. Any ideas why this does not work]?

0

There are 0 best solutions below