Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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?

Comments

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited January 2013

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • Options

    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*');
     }
    
  • Options
    businessdadbusinessdad Stealth contributor MVP
    edited January 2013

    @razhar Could you please clarify what exactly doesn't work? Does the event handler get called?

  • Options

    @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

  • Options
    x00x00 MVP
    edited January 2013

    Objects are passed by reference in php so doing &$Sender is not good. Just use $Sender

    Secondly. 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?

    grep is your friend.

  • Options

    @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?

  • Options

    That event is not attached to UserModel but EntryController, if in doubt grep.

    public function EntryController_RegistrationSuccessful_Handler($Sender) {
    
    }
    

    grep is your friend.

  • Options

    As simple as changing a word, huh? Thanks for the help!

  • Options
    businessdadbusinessdad Stealth contributor MVP

    @razhar said:
    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).

    For simple debugging, the good old var_dump() could be a better option, as it gives you immediate feedback. Besides, using PHP mail() 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().

  • Options

    @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

  • Options

    Hey guys, just looked around alittle bit and found the soulotion for that in another plugin. Thanks!

Sign In or Register to comment.