Campos de usuarios en drupal

Drupal

Desde nuestro módulo podemos añadir o modificar los campos de un usuario.


//set up the user fields
$fields = array(
'name' => $data['UID'],
'mail' => ( $GLOBALS['anonymous'] ) ? 'test-'.$data['UID'].'@test.com' : $data['Email'],
'pass' => $password,
'status' => ( $data['Locked'] == 0 ) ? 1 : 0 ,
// 'init' => ( $GLOBALS['anonymous'] ) ? 'test-'.$data['UID'].'@test.com' : $data['Email'],
'language' => ( isset($langs[$data['Lang']]) ) ? $langs[$data['Lang']] : $langs['default'] ,
'roles' => array(
DRUPAL_AUTHENTICATED_RID => 'authenticated user',
),

// User custom fields
'ces_firstname' => array(LANGUAGE_NONE => array(array('value' => $data['Firstname']))),
'ces_surname' => array(LANGUAGE_NONE => array(array('value' => $data['Surname']))),
'ces_address' => array(LANGUAGE_NONE => array(array('value' => $data['Address1']."\n".$data['Address2']))),
'ces_town' => array(LANGUAGE_NONE => array(array('value' => $data['Address3']))),
'ces_postcode' => array(LANGUAGE_NONE => array(array('value' => $data['Postcode']))),
'ces_phonemobile' => array(LANGUAGE_NONE => array(array('value' => $data['PhoneM']))),
'ces_phonework' => array(LANGUAGE_NONE => array(array('value' => $data['PhoneW']))),
'ces_phonehome' => array(LANGUAGE_NONE => array(array('value' => $data['PhoneH']))),
'ces_website' => array(LANGUAGE_NONE => array(array('value' => $data['WebSite']))),

);

$user_drupal = user_save('', $fields);
Leave a Reply

Your email address will not be published. Required fields are marked *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.

LesOlivex