Plugin events
Hey there,
I would like to develop a plugin that executes a script once a user has registered succsessfully. I looked up for the special event of the regiteration yet failed to fine it - can anyone direct me to the event's name?
0
Hey there,
I would like to develop a plugin that executes a script once a user has registered succsessfully. I looked up for the special event of the regiteration yet failed to fine it - can anyone direct me to the event's name?
Comments
This might be of help: http://vanillaforums.org/discussion/21910/execute-php-script-upon-user-registration
I've tried that, just to see if that's the one, but it doesn't really work... May you tell me what am I doing wrong?
email is a real email, by the way.
public function UserModel_RegistrationSuccessful_Handler(&$Sender) { mail(*email*', 'hey', 'hey', 'From: *email*'); }@razhar Could you please clarify what exactly doesn't work? Does the event handler get called?
@businessdad I actually don't know... I tried using the mail function to see if it's called by I didn't receive any email - so I assume it's not getting called
Objects are passed by reference in php so doing
&$Senderis not good. Just use$SenderSecondly. Make sure your mail setup is working. it already sends out emails. If you are not receiving them it is becuase you don't have one of the mailing options setup correctly like SMTP. Some host don't like SMTP so you have to go with an alternative.
As there is already a welcome email I can only assume that is the issue.
$Definition['EmailWelcomeRegister'] = 'You have successfully registered for an account at {Title}. Here is your information: Username: {User.Name} Email: {User.Email} You can access the site at {/,exurl,domain}.';You could simply expand on the definition to include the information you'd like.
Lastly instead of using a mail generic function, why not tie in with the framework's own email system?
@0xx Thanks for the response. The plugin has nothing to do with the email, actually, I just wanted to use it so I'll know the handler got called. The mail function is actually working outside of this script (I'm using it in other sites of mine).
I assume this is a problem with the handler function itself, maybe I'm just using it wrong?
That event is not attached to UserModel but EntryController, if in doubt grep.
public function EntryController_RegistrationSuccessful_Handler($Sender) { }As simple as changing a word, huh? Thanks for the help!
For simple debugging, the good old
var_dump()could be a better option, as it gives you immediate feedback. Besides, using PHPmail()could give you misleading results, as, sometimes, mail is sent successfully, but silently rejected by the destination servers as considered spam. I found an article that can give you more details: How to Pass Spam Filters with PHP mail().@businessdad Thanks for that, nice article - will sure help in the future. By the way, do you guys have any idea how to use perform an INSERT MySQL query? I found the answer for a SELECT one only...
Thanks
Hey guys, just looked around alittle bit and found the soulotion for that in another plugin. Thanks!