Программно создаем поля для профиля пользователя Drupal6.


$fields = array(
0 => array(
'title' => 'Who are you?',
'name' => 'test',
'explanation' => '',
'category' => 'custom',
'type' => 'selection',
'weight' => -10,
'required' => 0,
'register' => 1,
'visibility' => 3,
'autocomplete' => 0,
'options' => "individual\r\nbusiness",
'page' => ''
),

);

foreach ( $fields as $field ) {
db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')",
$field['title'],
$field['name'],
$field['explanation'],
$field['category'],
$field['type'],
$field['weight'],
$field['required'],
$field['register'],
$field['visibility'],
$field['autocomplete'],
$field['options'],
$field['page']
);
drupal_set_message(t('The field %field has been created under category %category.', array('%field' => $field['title'], '%category' => $field['category'])));
watchdog('profile', 'Profile field %field added under category %category.', array('%field' => $field['title'], '%category' => $field['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/user/profile'));
}
cache_clear_all();
menu_rebuild();
?>

Категория: 
The code has been tested and works

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.