Jump to content

Module to run PHP after successfull customer registration


Recommended Posts

Dear community,

i am trying to run some PHP Code after a new customer successfully created an account in our onlineshop. 
my question is where to insert this PHP?

i assume the best way is to write a module which calls the CustomerAccountAdd Hook ? (And how does the Code has to Look like)

And the PHP Code or rather the Module itself should get triggered whenever a new account gets successfully registered. Is this automatically happening or do i have to tell the CustomerAccountAdd Hook That it always runs the module after an account was successfully created? 

*Edit In this module i need to access the Email of the recently created account and Save as PHP var 

I would be very glad if someone could help me out.

 

My Code for my module looks like following: 

Anything i put in the hook function at bottom is not working...

 


<?php
if (!defined('_PS_VERSION_'))
  exit;
 
class SendEmail extends Module
{
  public function __construct()
  {
    $this->name = 'SendEmail';
    $this->tab = 'front_office_features';
    $this->version = '1.2';
    $this->author = 'Philip Zadeh';
    $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.4', 'max' => '1.7');

 
    parent::__construct();
 
    $this->displayName = $this->l('SendEmail');
    $this->description = $this->l('Activate to enable activation Emails for new Customers.');
 
    $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
 
    if (!Configuration::get('SendEmail_NAME'))      
      $this->warning = $this->l('No name provided');
  }
    
    public function install()
    {
        return parent::install()
            && $this->registerHook('actionCustomerAccountAdd');
    }
    
    public function hookActionCustomerAccountAdd($params)
    {
        
    }
}
?>

Best regards,

Philip Zadeh

 

Edited by philip1895
Adding Module Code (see edit history)
Link to comment
Share on other sites

  • 3 months later...

This hook is executed when a new account is created, and you can get the Customer object like this:

public function hookActionCustomerAccountAdd($params)
{
	$customer = $params['newCustomer'];
	$email = $customer->email;
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...