Warning message

Newsletter category Drupal Developer newsletter format has not been set to HTML. There will be no statistics recorded for this newsletter.

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.

CodeLet: 

//$Id$

/**
* @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'];
break;
}
}

User profile upload | Drupal Developer

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

Add comment

Log in or register to post comments
QR code for this page URL This page URL
Feedback