This is an old revision of the document!
Table of Contents
Drupal Tips
Some hints, tips and code samples for managing and extending Drupal.
Cron
Directory Structure
Externally Managing Users & Roles
Moving A Site
Programmatically create drupal user and then store UID of new user
While looking for a means of extracting a userid from an account I came across the following article:
From the above I came up with the following to obtain a uid from a name. The delete_user needs a uid so this was my way of getting the uid. $account = user_load_by_name($name); $uidn = $account→uid; ===== Updating Custom User fields ===== I added a custom field to the user object and needed a way to programmatically put data into that field. I found the following code on Drupal: $user_fields = user_load($user→uid); $user_fields→field_points['und'][0]['value'] = $points; user_save($user_fields); This comes from the following Drupal page: * Updating User Fields in Drupal 7 The actual code that worked retrieved a user, updated the field and then saved it back follows. The field name is 'field_lname. $field_data = 'Glembocki'; $name = 'tomg'; $user_fields = user_load_by_name($name); $user_fields→field_lname['und'][0]['value'] = $field_data; user_save($user_fields);