Thursday, September 17, 2015

How to add extra fields to user profile in Drupal?

Step 1. - Create custom module -For Example My custom module name is extra_user_profile
Folder Name - extra_user_profile
Files - extra_user_profile.nfo, extra_user_profile.module, extra_user_profile.install

Step 2.
extra_user_profile.nfo file:-
name = Extra User Profile
description = Add new field in user profile
core = 7.x
version = "7.x-2.5"
core = "7.x"

Step 3.
extra_user_profile.module file:-

Step 4.
extra_user_profile.install file:-

 * Implementation of hook_enable().
function extra_user_profile_enable() {
  // Check if our field is not already created.
  if (!field_info_field('field_nickname')) {
    $field = array(
        'field_name' => 'field_nickname', 
        'type' => 'text', 

    // Create the instance on the bundle.
    $instance = array(
        'field_name' => 'field_nickname', 
        'entity_type' => 'user', 
        'label' => 'Nick Name', 
        'bundle' => 'user',
        'required' => TRUE,
        'settings' => array(
            'user_register_form' => 1,
        'widget' => array(
            'type' => 'textfield',
            'weight' => '1',

Step 5 Enable Module

Now Nickname field is available in User profile page


  1. Its The Best information for my drupal website design and development team so i have a shared to my team and also shared to my social media sites..Thank you for sharing the informative information....Best Web Development Company Bangalore | Best Website Development Company in Bangalore

  2. Wonderful post! You've made some very astute observations and I am thankful for the the effort you have put into your writing. Its clear that you know what you are talking about. I am looking forward to reading more of your sites content.
    happy wheels online | coolmath games | run 3 game | happy wheel online | cool maths 4 kids | game run 3 online

  3. Really an awesome post. I wondered by reading this blog post. Thanks a lot for posting this unique post which you have shared with us. Keep on posting like this exclusive post with us.

    Salesforce Training in Chennai


only show translated menu items into current language (Drupal 8)

function MY_THEME_preprocess_menu(&$variables) {   if ($variables['menu_name'] == 'brancott-header-menu') {    $langu...