How to trigger a hook after signup

    • 36 posts
    August 20, 2018 9:06 AM EDT

    I have created a new module that adds phone verification step to the signup process. The problem I have is that I cannot update the users table after the signup process with the phone number received. I tried registering a hook in application/modules/mymodule/settings/manifest.php as follows: 

    'hooks' => array( array( 'event' => 'onUserCreateAfter', 'resource' => 'User_Plugin_Phone', ), ),

    Then, I created the class User_Plugin_Phone in application/modules/User/Plugin/Phone.php as follows:  

    class User_Plugin_Phone extends Core_Plugin_Abstract { public function onUserCreateAfter($event) { echo 'console.log("Inside User_Plugin_Phone::onUserCreateAfter");'; echo 'alert("Inside User_Plugin_Phone: onUserCreateAfter");'; $payload = $event->getPayload(); } }

     

    But the hook is never triggered after signup completes. Tried many times. Any ideas will be appreciated.


    This post was edited by mehdi at August 21, 2018 12:15 AM EDT
    • Moderator
    • 6923 posts
    August 20, 2018 1:38 PM EDT

    Please remember what we said in the last thread about code. Your code is not in tags. Normally, we delete as per our posted rules. Please edit your post.

    • 36 posts
    August 21, 2018 12:15 AM EDT

    Hi Donna. Fixed that. Thanks

    • Moderator
    • 6923 posts
    August 21, 2018 4:35 AM EDT

    Are you trying with a standard Profile Question for the phone number? If not, perhaps try that as it already has the routine to save to db and would take less code since that process is already there.

    • 36 posts
    August 21, 2018 7:02 AM EDT

    No, I have added a new step and even created its admin form. The problem is I don't know how to update the users table with the phone number I have received from the user in my new signup process. I tried that in the onSubmit() method of the new class, but in that stage, the viewer has always an identity of 0 and I cannot update it.  

     

    Engine_Api::_()->user()->getViewer()->getIdentity();
    This post was edited by mehdi at August 21, 2018 7:11 AM EDT
    • Moderator
    • 6923 posts
    August 21, 2018 10:35 AM EDT

    Not sure why you don't want to try the default Profile Questions and then tie your plugin into that question. Grab it and use it. Other than re-creating the wheel.

    • 36 posts
    August 21, 2018 4:52 PM EDT

    I am not sure if that will work for me. Actually, I will need to get the phone number, which I can do now, no problem. But, I have problem saving the number at the end of the registration. It's not clear which methods in which classes are invoked after registration is done.  

    Further, my module will need to serve my mobile app too, serving as a small REST API too.