Lee
Lee

Reputation: 1495

Magento - Change newsletter sign up

I'm still getting to grips with Magento CE 1.8.1.0, what I'm trying to do is figure out where the code is for the newsletter subscription on account creation.

We don't use the standard Magento newsletter, our addresses are stored in 3rd party software. Ideally I'd like it if when the user clicks the submit button, it adds the email address to a seperate database, but to do that I need to find out where the code is.

I've found the account sign up page here:

/app/design/frontend/default/yourhealthfoodst/template/persistent/customer/form/register.phtml

And the Newsletter checkbox here:

<input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" checked="checked" class="checkbox" />

The submit button if part of this form:

<form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="form-validate">

And from what I can gather, $this->getPostActionUrl() is:

/customer/account/createpost/

I'm just struggling to find the next step... if that makes sense!

Thanks for any advice

Upvotes: 1

Views: 594

Answers (2)

user439441
user439441

Reputation:

Newsletter subscription for customer is in the Mage_Newsletter_Model_Subscriber class in the subscribeCustomer method, line 389. This method is called from the subscribeCustomer method of Mage_Newsletter_Model_Observer on line 34, listening on the event customer_save_after.

When the user submits the form on the customer/account/create page, the form calls the customer/account/createpost controller action in Mage_Customer_AccountController on line 264. The controller loads the customer model, fills the customer data and saves to the database. When the customer is saved, the customer_save_after event is dispatched and Mage_Newsletter_Model_Observer, having registered for the event, is sent that customer. The newsletter observer than subscribes the customer.

Upvotes: 1

Techroshni
Techroshni

Reputation: 541

I am not sure if you have basic understanding of mapping the URL request to the file system where it is processed.

/customer/account/createpost/

It says the action which is going to execute lies inside

app/code/core/customer(module)/account(controller)/createpostAction(action function) path but as you say that it is saved at 3rd party then there must be a module either in local or community pool which is overiding this controller.

To check that, perhaps you can look for a module with package name similar to your third party vendor. Then, inside that module you can see the action function for this form post.

Upvotes: 0

Related Questions