Drupal: Add user avatar on registration page

This CodeLet adds a field on Drupal registration form and allows the user to upload an avatar. This will be saved to user's picuture field on his/her profile. This will work only if 'Picutre' is enabled by the admin.

User profile upload | Drupal Developer


* @file
* Allow a user to upload a file or image from the user's profile page
* @author DrupalD

* Implementation of hook_user
* @param $op
* @param $edit
* @param $account
* @param $category
* @author DrupalD
function user_upload_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'register':
case 'form':
$form['user_picture'] = array(
'#type' => 'file',
'#title' => t("Your Avtar"),
return $form;
case 'insert':
$account->picture_upload = $edit['user_picture'];

Is CodeLet useful?: