Hi, I am using my sign-up form (not amember's) in my website. So, after getting the user information, I call amember api to add the user to amember's user table (as written in http://www.amember.com/docs/REST_API_examples). I also want to automatically login the user after signup. I have already checked this option in admin CP, but unfortunately the user does not get logged in after sign up. To resolve this, I decided to write a hook in my plugin to do the login action whenever the signup is complete. I added the "signupUserAdded" hook, but it's never called. Does anybody have a recommendation of what I should do? Thanks.
API does work with database directly, so hooks will not be executed. Here is the idea how this could be done: Each plugin in aMember have directAction support when you can pass request to plugin for example: /amember/protect/pluginname/action This will be passed to your Am_Protect_Pluginname::directAction method. So you can do this: 1. Include link to your plugins's direct action as an image or javascript after signup. For example: <img src="/amember/protect/pluginname/login?user_id=1&hash=SOME_SECURITY_HASH_UNIQUE_FOR_USER_AND_SESSION" width=0> Image will be hidden for user, the idea is to execute login code in user's session in background. 2. In your plugin derectAction method, validate hash, and if it is correct, login user into system.
Sorry for jumping on an old thread, but I need exactly the continuation of this thread...on step 2 above: How do I log the user into the system at that point? Thanks.
PHP: $user = Am_Di::getInstance()->userTable->load($user_id);Am_Di::getInstance()->auth->setUser($user, $_SERVER['REMOTE_ADDR']);