Hi, my users are joining and few are uploading pictures. Its important that every account have a picture associated with it to us. How can we force people to upload a picture to create an account?

Comments

Fusion_Sushi’s picture

I think not.
_____________________________________________________________
"You can always find the storm by listening for the Thunder."

"You can always find the storm by listening for the Thunder."

Yes, my name used to be c4.Pilgrim.. decided to change it

hitesh pherwani’s picture

Hello,

For picture upload for the anonymus users in the registration form is possible.
We used Logintoboggan module in that module in the below function

function logintoboggan_form_alter($form_id, &$form)
{
//lines of code
//in the end of the functuion add these lines
//

if (variable_get('user_pictures', 0)) {
    $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);

    $form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture.  Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''));

    $form['#attributes']['enctype'] = 'multipart/form-data';

}

and for the upload to be made required use logic in the validation code of the user module.
Regards,

Hitesh

Regards,

Hitesh

awardpromo’s picture

this doesn't work for me on Drupal 5.0.
The uploaded picture gets the filename "picture-.jpg", the uid is missing. Still investigating whats wrong with my setup, but you should doublecheck your uploaded files ;) And check your upload with a different picture as the picture from user/1,
otherwise you won't notice the failure because the pic from user/1 is shown in the profile.

**********************************************************
ROYAL HERITAGE LOTTERY INTERNATIONAL
HEADQUARTERS UNITED KINGDOM.

Dear Lucky Winner,
We happily announce to you

ncameron’s picture

Worked like a charm for me. Followed the instructions given and all worked. Two things to remember:

1) Watch out for the braces (curly brackets) when you paste the above block. You will see a series of if statements, it should follow that.

2) You need to enable one of the functions in LOT for it to take affect. I chose the 2 email fields option

Good luck!
Neil

- Connecting Language Learners
www.huitalk.com

--
Open Source Web Solutions
http://cameronandwilding.com

ncameron’s picture

Actually, this gave us a real headache. Had the same problem as above, all the pics had the same file name so users ended up with the same image.

- Connecting Language Learners
www.huitalk.com

--
Open Source Web Solutions
http://cameronandwilding.com

phazer’s picture

I've been trying to get this to work for a couple of hours, I tried it in the login toboggan and I made my own hook_form alter and put the code in it. I have Drupal 5, and all my pictures are being saved as picture-0, I've tried lots of stuff with hook_user, but I can't overried the $edit->picture which is set to 0

Would love to hear if someone with D5 has picture upload supported on their registration form.

reset.to’s picture

write your own form_alter function as mentioned above. than add your validate function.

<?php
function mymodule_user_register_validate($form_id, $form_values, &$form){

   
// If required, validate the uploaded picture.
   
if ($file = file_check_upload('picture_upload')) {
       
// getting next id - you cannot use db_next_id!!
       
$res = db_query('SELECT MAX(uid) uid FROM {users}');
       
$user = db_fetch_object($res);
       
// this is now our future user
       
$user->uid++;
       
user_validate_picture($file, $edit, $user);
    }
}
?>

now the $edit["picture"] will be filled by the call of user_validate_picture. Thus you have to prevent an error when the user.module call it's own hook_user. So simply add this line:

<?php
function user_validate_picture($file, &$edit, $user) {
  global
$form_values;
  if(
$user->uid == 0 ) return;

 
// function continues here ...
}
?>
stella’s picture

Try the avatar_selection module. It may or may not suit your needs.

gauravkumar87’s picture

Hey,

I wanted to let a user select an avatar on the user registration page. Although the "avatar_select" module gave me the option of selecting pictures, it didnt help me with the uploadin bit.. as in i couldnt see an upload ur image field (although i had picture enabled for users). So this is wat i did... hope it helps out some of you

modification to avatar_selection_form_alter() :

look for the if('user_register'==$form_id) part which specifies that u r modifying the registration form...
and add the following lines after $upload=1;

$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);

$form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' =>
variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''));

$form['#attributes']['enctype'] = 'multipart/form-data'

Cheers

Gaurav

-Gaurav

Piya’s picture

I have made the changes in the module 'logintoboggan' as per above code..The problem is images upload part appears on every page.
Please help me to solve this problem...

Thanks in advance....

gauravkumar87’s picture

@piya:
i made the changes in the avatar selection module . Anyways if u have to use login toboggan make sure u have altered the registration form and nothin else...

Cheers

Gaurav

-Gaurav

Piya’s picture

Hii..
I am actually facing problem for avtar and logintoboggon module's combine effects...

I am using drupal 6.x...

I have to include all avtar registerd by admin and also to give a facility to user that he also can upload the images while registraion..

Can u sugest me any way for that in drupal 6.x...?

Thanks in Advance

gauravkumar87’s picture

piya, i faced the same issue..
this is when i modified the avatar select module...

basically u have to modify the registration form... so in the module find avatar_selection_form_alter() (this is a hook to alter any form).
now.. inside this look for if('user_register'==$form_id) .. this specifies that u r tryin to modify the registration form..

now place the code mentioned above to it.. wat it does is basically it adds an upload field to the registration form in the avatar select fieldset... i think thats exactly what u r looking for... and u dont need login toboggan if u r usin it for only this purpose.

Cheers

Gaurav

-Gaurav

Piya’s picture

Hi...

I have written following code in the avatar_selection_form_user_register_alter() after $upload = 1;

if('user_register'==$form_id)
{
$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);

$form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' =>
variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''));

$form['#attributes']['enctype'] = 'multipart/form-data';
}

but

1) It is only showing uploaded picture in profile edit page
2) No option for upload in the registration form for new user

stella’s picture

Try out the Register with Picture module.

scottatdrake’s picture

We have a winner! That module is perfect for what I need. Thanks.