Need help buying now? +48-22-219-5163 +1-917-720-3250
My Cart

Your Cart is Empty

Need help buying now?
+48-22-219-5163 +1-917-720-3250

Twitter handle

Twitter handle

There are currently a lot of social services that allow not only monitor the events in any part of the world but also use their data in promotion and improvement of your business. One of the most popular social networks in the world is Twitter. Let us review how to add the line ‘Twitterhandle’ into Magento registration form.

Why is this necessary?

Many services that create and store visiting statistics data of web shops, blogs and diaries use the information from Twitter in their work. These include link referrals, reviews, etc. If you wish to know your customers’ opinion about your store – this is the best way you could ever find.

Besides, this social network will help you significantly increase the amount of potential customers and monitor the activity of customers you already have. It is quite simple to add ‘Twitterhandle’ field to the registration form, all you need to do is slightly correct the code. Also check our free Social Connector.

Many web store owners tend to underestimate the power of Twitter. This is what this microblog network can give you:

1. Information about your customers, their problems, needs and requirements;

2. Public opinion about the products of your company and about other companies (your possible competitors);

3. Possibility to help your customers make the right choice or give them an idea of buying this or that product;

4. Free promotion of your web store products;

5. Free advertisement of your products directly to the target audience.

How to add Twitterhandle

As we mentioned in other articles, Magento uses the following architecture of the data: Entity – Attribute - Value. Based on that information, you only need to add another attribute in order to have the line for Twitter. For that you need to edit the file register.phtml. You will find it at the path app, then app\code\local\YourNamespace\Appname\sql\yournamespace_appname_setup\mysql4-install-1.0.php

Open the file in the editor and paste the following code at the beginning:

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'twitter', array(
'label' => 'Twitter handle',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => false,
'position' => 1


In order to configure in which place the social network line will be located, find the following part in the file:

<label for="email_address"><?php echo $this->__('Email Address')
?><span class="required">*</span></label><br/>
<input type="text" name="email" id="email_address" value="<?php
echo $this->htmlEscape($this->getFormData()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="validateemail
required-entry input-text" />


You can find it using the combination of ctrl + F.

After closing tag </li> paste the following code:

<label for="twitter"><?php echo $this->__('Twitter handle') ?></
<div class="input-box">
<input type="text" name="twitter" id="twitter" value="<?php
echo $this->htmlEscape($this->getFormData()->getTwitter()) ?>"
title="<?php echo $this->__('Twitter') ?>" class="input-text" />
<label for="twitter" style="color: #ccc;font-size:
85%;">Example: @packtpub</label>


Note that this line will be highlighted in bold text to attract the attention, you can remove this point if necessary.

Remember that sometimes your customers will need to update the information on their social network page. In order to let them do it directly from your store you need to modify the file edit.phtml.

Open the file in catalog customer/form/ and look for the following code:

<label for="email" class="required"><em>*</em><?php echo $this-
>__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="email" id="email" value="<?php
echo $this->htmlEscape($this->getCustomer()->getEmail()) ?>"
title="<?php echo $this->__('Email Address') ?>" class="input-text
required-entry validate-email" />


Below that code add the following:

<label for="twitter"><?php echo $this->__('Twitter handle') ?></
<div class="input-box">
<input type="text" name="twitter" id="twitter" value="<?php
echo $this->htmlEscape($this->getCustomer()->getTwitter()) ?>"
title="<?php echo $this->__('Twitter') ?>" class="input-text" />
<label for="twitter" style="color: #ccc;font-size:
85%;">Example: @ferdous</label>


After that you need to change the template configuration file. For that, go to app/code/core/Mage/Customer/etc/, then open the file config.xml.

Basic changes will be done in Global, you need to replace that block with the following:



Now you are almost finished. You only need to add an object attribute. Go to app/code/core/Mage/Customer/Model/Entity/ and open file setup.php. Locate the fields responsible for customers’ email address, but remember that after any Magento update all modifications in the core files will be erased. In that case do not forget to add them again:

'email' =>array(
'type' => 'static',
'label' => 'Email',
'class' => 'validate-email',
'sort_order' => 60,


Add the following code:

'twitter' => array(
'label' => 'Twitter',
'required' => false,
'sort_order' => 65,


It is done. Save the changes and check how it works. The code was taken from

If you would like GoMage specialists to help you install Twitterhandle in Magento please email us directly or leave a comment to this article. We will highly appreciate if you share your knowledge and opinion regarding using Twitter data for the improvement of the web store operation.