I have created a custom page in magento, from this I want to send coupon code to customer which are new and already registered both. For this I have created a custom form with all information I needed, on submit form I am calling a ajax and my custom module handle this request.

But How to identify there that it is new customer and How to create a new customer account in controller action?

  • Pls check my answer it will helps you. Oct 20, 2016 at 10:57

2 Answers 2


Try something like below:

$customer_email = '[email protected]';  // email adress that will pass by the questionaire 
    $customer_fname = 'test_firstname';      // we can set a tempory firstname here 
    $customer_lname = 'test_lastname';       // we can set a tempory lastname here 
    $passwordLength = 10;                    // the lenght of autogenerated password

    $customer = Mage::getModel('customer/customer');
    * Check if the email exist on the system.
    * If YES,  it will not create a user account. 

    if(!$customer->getId()) {
    try {

        // Send welcome email
        $storeId = $customer->getSendemailStoreId();
        $customer->sendNewAccountEmail('registered', '', $storeId);
        //Make a "login" of new customer

    catch (Exception $ex) {
       echo 'error';

use this code for check Customer Exist

$customer = Mage::getModel('customer/customer');

  "Customer Exist";

add add this this code https://www.onlinecode.org/customer-rgistration-programmatically-magento/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.