Step 1. - Create custom module -For Example My custom module name is extra_user_profile
Folder Name - 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:-
<?php
Step 4.
extra_user_profile.install file:-
<?php
/**
* 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',
);
field_create_field($field);
// 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',
),
);
field_create_instance($instance);
}
}
Step 5 Enable Module
Now Nickname field is available in User profile page
Enjoy....!!!!
Enjoy....!!!!
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
ReplyDeleteNice information about adding extra field in drupal.
ReplyDeleteMacrosoft's Address Forever App lets you port your current address wherever you move