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.



* @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(
'' => 'file',
'' => t("Your Avtar"),
return $form;
case 'insert':
$account->picture_upload = $edit['user_picture'];

User profile upload | Drupal Developer

By DrupalD on Sat, 03/08/2013 - 12:24pm

Add comment

Log in or register to post comments

Try GSuite and get 20% discount for first year