전화 번호 및 CV와 같이 drupal 7의 사용자 프로필에 필드를 추가하는 모듈을 개발하고 싶습니다 ... 및 그 작업을 수행하는 방법을 모르겠습니다. (데이터베이스 또는 필드 API 사용) pls help me.
명확한 자습서를 제공해 주시면 감사하겠습니다.프로그래밍 방식으로 Drupal 7의 사용자 프로필에 새 필드를 추가하는 방법
0
A
답변
5
다음 코드이 작동
$myField_name = "NEW_FIELD_NAME";
if(!field_info_field($myField_name)) // check if the field already exists.
{
$field = array(
'field_name' => $myField_name,
'type' => 'text',
);
field_create_field($field);
$field_instance = array(
'field_name' => $myField_name,
'entity_type' => 'user', // change this to 'node' to add attach the field to a node
'bundle' => 'user', // if chosen 'node', type here the machine name of the content type. e.g. 'page'
'label' => t('Field Label'),
'description' => t(''),
'widget' => array(
'type' => 'text_textfield',
'weight' => 10,
),
'formatter' => array(
'label' => t('field formatter label'),
'format' => 'text_default'
),
'settings' => array(
)
);
field_create_instance($field_instance);
희망 ... 무하마드을 따르도록하십시오.
2
당신은 PROFILE2 모듈을 사용할 수 있습니다 http://drupal.org/project/profile2
덕분에 내가이 D7에서 나를 위해 일하고있다 그것을 – aladein
를하려고합니다 - 감사합니다. –