Nâng cấp Drupal User Profiles với Profile2

Nâng cấp Drupal User Profiles với Profile2

Drupal 7 has made it easy for you to allow your site users to share information about themselves. User accounts are now "entities" which means that you can add fields to them, just as with content.

You can add user profile fields for names, email addresses, phone numbers, resumes or whatever else you might need.

However, there are some limitations to the core user profile. What happens if you don't want user accounts visible to the public? What happens if you need different profiles for different areas of your site?

The answer is the Profile2 module.

Profile2? Drupal 6? Drupal 7?

Profile2 is only available for Drupal 7 sites.

For those of you with experience building sites in Drupal 6, let me explain why it's not needed for Drupal 6. In Drupal 6 you have the core Profile module. However, that did not make it into Drupal 7.

The Content Profile module was also a good option for Drupal 6 sites.

In Drupal 7, the Profile2 module creates a profile entity similar to how a node is an entity, a user is an entity, a vocabulary term is an entity. Because profile is an entity, we can add fields to it and we can have more than one.

To understand what Profile2 does, let's take a look.

The default user profile

By default, Profile2 provides one profile type. You can see an example below. The screenshot shows that we have added three fields to the main profile: image, name, and bio.

media_1357318737630.png

Install Profile2

There are two modules required for Profile2 to work.

  • Profile2 located at http://drupal.org/project/profile2
  • Entity API located at http://drupal.org/project/entity

Install the modules to your site and you will be able to see them in your module list.

  1. Click on Modules in the black admin menu bar.
  2. Check the box next to Profile2 and Profile2 pages.
  3. Save configuration.
  4. Drupal is smart enough to know which modules are required and will now prompt you with a list of modules it will enable for you. They include the Entity API module.
  5. Click continue to finish enabling the modules.

Configure the Profile2 module

  • Go to Structure > Profile types.
  • Click Add profile type.
  • You'll now be able to add a completely new profile type with different fields and different display options.
  • The screenshot below shows the default main profile and the Community profile I added using the Add profile type link shown on the screen.

media_1357319435116.png

Edit the Profile Type

As you can see from the screenshot below, there are just a few options to consider for each profile type.

media_1357319628739.png

The first checkbox will give the users access to their profiles if they edit their user accounts.

The second option will add links to the profiles to the User menu so that your users can edit them. Here's how the profile links might appear:

media_1357319003827.png

Add Some Fields

From inside the Structure > Profile 2 area you can add field to each profile type. 

media_1357319903411.png

Other Configurations to Consider

In addition to the settings discussed above, below are few others to consider.

  • User Accounts: You still have the option of adding fields to your user account but you'll want to plan which ones will be a part of the user account and which will be on the profile. You don't want your users duplicating effort if not necessary.
  • Roles: If you want the profiles to be available to specific users on the site, consider added a role that can be assigned to a user and thus give them permission to view or edit the profile(s).
  • Permissions: Whether you have a separate role or not, remember to set permissions (see your options in the screen shot above).

Nâng cấp Drupal User Profiles với Profile2

Summary

If you are having a hard time envisioning how Profile2 can be used on your site, consider the following use case (borrowed from http://drupal.org/node/1114454 .)

"One profile stores contact information (address, city, etc) and this information through the permissions is able to be edited by the user. The second profile is information that is related to a user's membership, so things like membership ID, year joined, etc. This information is such that it can be viewed by the user, but not edited."

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Hướng dẫn migrating content sang Drupal 8 năm 2015

Hướng dẫn migrating content sang Drupal 8 năm 2015

When Drupal 7 was released, it came with an upgrade script that would convert a Drupal 6 database into a Drupal 7 database

Hướng dẫn thay đổi độ giãn chữ trong word

Hướng dẫn thay đổi độ giãn chữ trong word

Sau khi kích nút OK, đoạn font chữ đã chọn sẽ có kết quả nhấp nháy theo loại đã chọn ở ô Animations

Kindle Fire bị phàn nàn lỗi Wi-Fi

Kindle Fire bị phàn nàn lỗi Wi-Fi

Cnet dẫn thông tin từ trang công nghệ Electronista cho biết, người dùng Kindle Fire nhận thấy khả năng bắt sóng Wi-Fi của chiếc máy tính bảng này khá yếu.

Công ty diệt chuột T&C

 

Diet con trung