1

In Drupal 7 is it please possible to enforce all new users to upload an avatar picture during the registration process? I.e. how to make the user picture field mandatory?

When I try to edit the registration form fields at /admin/config/people/accounts/fields there are no settings for the user picture, I only see it being an account widget:

enter image description here

2
  • Please switch your site to English when taking screenshots. It'll make it easier for us to understand what's the problem. fields can be set to be required, shouldn't be a problem.
    – Mołot
    Nov 18, 2013 at 15:25
  • @Mołot I have uploaded english screenshot. Please tell me, how to set the avatar field to required, I don't see any settings for this. Nov 21, 2013 at 12:57

4 Answers 4

6
+100

Sounds like you need the register with picture module

enter image description here

3
  • Thank you, I hope it works well tih Drupal 7.24 and will migrate the existing user avatars too... Nov 21, 2013 at 14:56
  • No worries. I hope it does what you need. Nov 21, 2013 at 14:58
  • Yep, I didn't know of this module. @AlexanderFarber , please let us know what happened, if it was a good solution. Regards Nov 22, 2013 at 9:20
5

Can you use hook_form_alter. UPDATE : this hook_form_alter must be put in a custom module, lets say mymodule the location of this module will be sites/all/modules/mymodule.

In order to use dpm(), you need to install the Devel module.

Here you can have a tutorial, explaining the basics for creating a custom module. In your case, this is going to be only .info file and a .module file. The hook_form_alter should look like

/**
* Implements hook_form_alter().
*/
 function mymodule_form_alter(&$form, $form_state, $form_id) {
  drupal_set_message("Form ID is : " . $form_id);
  dpm($form,'form');
 }

A lot of nice snippets can be borrowed from here. drupal forum . After that you can use dpm ($form, 'form');

And see exactly the construction. Those forms use the Drupal 7 Form API construction mechanism. The idea would be to add '#required' => TRUE to the corresponding image field. I hope this helps in a way.

UPDATE: Do not forget to clear your caches(even twice) after enabling a module. Otherwise, some hooks (but not all) will not be recognized. This problem only caused a lot of frustartion when working with Drupal.

Best regards ! Oleg

3
  • I have installed the devel module on my Drupal 7.24 website and added the line dpm ($form, 'form'); to the function hook_form_alter in the file modules/system/system.api.php but unfortunately I don't see any additional information in the browser, when registering as a new user? Nov 21, 2013 at 14:01
  • 1
    I will clarify it in the edited answer Nov 21, 2013 at 14:07
  • 1
    IMPORTANT: In the permissions of Devel information, add anonymous user to see debug information. Nov 21, 2013 at 14:21
0

I think you can add a new image field, called 'avatar' and mark it as required in the field's settings.

1
  • Yes I could do that (same as I added the field "gender" and "city" and made them mandatory), BUT: that image wouldn't be shown as user pic at the user profile page and in blog/forum comments. That is why I'd better would like to find out, how to to make the REAL avatar mandatory. Nov 21, 2013 at 13:19
0

user picture field module allow you add an image field to user, and show it on user register form, after user register an account, this module will use the fid that upload by image field as user picture's fid. Usage:

1, Add a image field to user, for example "field_user_avatar"

2,config this field,and make it show on user register form.

3,install this module, navigate to "admin/config/people/user_picture_field", here you can config the "Machine name of source field that used as user picture"

When user register an account, he/she upload an image through image field "field_user_avatar", this image will be used as user's picture(avatar).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.