How to Build User Profiles With Fields in Drupal 8

How to Build User Profiles With Fields in Drupal 8

By default, a Drupal 8 user account collects only very basic information about the user.

And, most of that information is not visible to visitors or other users on the site.

Fortunately, Drupal makes it easy to modify and expand this profile so that people can add useful information about themselves such as their real name (versus a username), address, employer, URLs, biography, and more.

If you’re new to how Drupal handles users, read this tutorial before starting. In this tutorial, I’m going how to create expanded user profiles for your Drupal users.

First, let’s add some fields to your user profiles. This allows users to provide more information about themselves.

  • Go to “Configuration”, “People”, “Account settings”, and then “Manage fields”. You can now see a screen which looks the one below:

manage fields

Let’s add the following Text (plain) fields:

  • First Name. Set the “Maximum length” to 50 characters.
  • Last Name. Set the “Maximum length” to 50 characters.

Next, add the following Link fields:

  • LinkedIn
  • Facebook
  • Personal Website

fields user profile

  • Go to the “Manage display” tab and arrange the new fields in the order you want them to show to site visitors.

manage display user fields

  • Go to “People” and “Permissions”.
  • Give the “View user information” permission to the Anonymous and Authenticated users.

view drupal user information

Now, go and see those user profile fields that you just created:

  • Click your user name to go to “My account” in the black menu bar at the top.
  • Click the “Edit profile” tab.
  • Scroll down and you can use all the fields that you just created.
  • Fill in the fields.
  • Save your data and click the “View” tab to see your profile:

drupal user profile

Now, see how these fields appear to your site’s users. For many users, this user profile editing area should look similar, but slightly different:

  • You can use the Masquerade module to see the site as the user would. If you’re not familiar with Masquerade, read this tutorial.
  • Click the article writer name to go to “My account”.
  • Click the “Edit profile” tab and see what the user sees:

drupal article writer

Finally, see how this appears to a new user:

  • Log out or visit your site in another browser.
  • Visit http://[your_web_address]/user/register
  • The registration screen should show the default Drupal fields, plus your new fields:

new user registration

If you want to remove any fields from the registration area, you can hide them by going to “Configuration, “People”, “Account settings”, and then “Manage form display”.

Want to Learn More?

This tutorial was an extract from Drupal 8 Explained, the best-selling guide to Drupal 8. Grab a copy today to learn all the fundamentals of Drupal 8.

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
Bruce
Bruce
4 years ago

Hi, I am working with a distribution called Open Social and have reached out to that community but haven’t gotten a reply, so I thought I’d pose the issue here:

Re: User Profiles (Drupal 8.7.11)
‘/admin/config/people/profile-types/manage/profile’

Does anyone know what must be enabled in order to add and modify the profile fields.

I have worked with these many times including in local instances of the same distribution.

But for the life of me cannot remember what must be enabled to get access to the fields tabs!

Here are two screenshots. One with the fields available and the other without!

Thanks

1
0
Would love your thoughts, please comment.x
()
x