Drupal module: User Picture Field - A Brilliant Solution for Styling forms With Display Suite

| Drupal Development | 5 seen

Working with complex Drupal projects I'm always trying to escape many rewrites of existing Drupal built-in functionality.

This time I got a client's request to have a user edit form with two-level admin: One for username and password information - the second for custom user profile fields, like occupation, location, gender, etc.

At the start I said - well, let's use the Profile2 module, to handle this task, but soon I found there are bugs, and we all hate bugs, so I found a brilliant solution how to get rid of the Profile2 module, but to keep existing functionality.

Now arrived another problem - how to display the default Drupal user picture ($picture) using the Display suite module on two columns. Thing is, there are no problems to display a custom user image field with help of the Display suite, but there are problems to display the default picture field:

Found this little nice module after a couple of hours of investigating how to show the user picture next to comments. 

You might wonder - hell, what's wrong with you dude - Drupal has a built-in picture field for user profiles and it works on comment forms great.

Yes, you are right, Drupal does have a picture field for user profiles.

But it doesn't play nice in scenarios when you are using Display Suite to style your form - this field just doesn't exist in Display suite. So you cannot put this field in column "two" for example:

Take a look at this post to understand what I'm talking about: Drupal Display Suite Two Columns on User Edit Forms + Image Widget Default Image 

What I actually needed is to have a default user picture field enabled but with the option to style its display with help of the Display Suite module, and here comes the User Picture Field module:

This module allows you to add an image field to a user, and show it on the user registration form after the user registers an account, this module will use the fid that uploads by image field as the user picture's fid.

Usage:

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

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

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

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

profile2:

Now this module support Profile2, You must config 'Machine name of source bundle' and 'Machine name of source field that used as user picture'.

Author:

Howard Ge

The author can be contacted for paid customizations of this module as well as Drupal consulting and development.

Now - once you have this module installed configure it according to description, keep using Display Suite and everything should work as needed.

P.S. This little nice module solved another problem I'm facing by using Simple FB connect module to allow Facebook users to login in Drupal site.

Simple FB Connect uses default picture field as well for importing a Facebook users picture.

So by having default profile picture field, but with a little bit of extended functionality.

I can only confirm - avoid of rewriting Drupal default behaviour - in most cases you will struck to extend functionality. Look for simple "bridge" connectors.

In case you are looking for Drupal website developer for your project, look no more - hire me