Drupal How To: Content Profile Basics

March 22nd, 2009 · 26 Comments

A Good Profile Is Key

A Good Profile Is Key

In Drupal complex tasks can be very easy.  Sadly many times simple tasks can be complex.  Even more often, to make a complex task simple, you have to make a simple task complex first.  Such is the case with the content profile moduleNote, this example uses Drupal 6.

Why Do I Want Content Profile?

The content profile module allows you to define a content type to represent your users profiles.  This allows a tremendous amount of customization without dealing with code.  You can use the CCK to define very complex node types to represent your users profiles.  We will get to doing that later, unfortunately getting to the point where your content profiles look like…well…profiles takes a bit of doing.  Be aware that there are many ways to do Profiles in Drupal and this is just one option, be sure you need this flexibility before you start down this path.

Setting Up Content Profile

First of course you have to install the content profile module and the CCK.  You’re on your way now.  Once the module is installed it will have created a profile content type.   Great.  Unfortunately you have a bunch of steps to go before it is usable at all.  The first thing we need to do is designate that it’s a profile type by going to Administer->Content Types->Profile->Edit. In the last section, “Content Profile,” you will find a checkbox that reads “Use this content type as a content profile for users.”

Unfortunately of course a normal user can’t edit this content type, so go to Administer->User Management->Permissions and give your logged in users permissions to create and edit thier own Profile content.  You do not want them to be able to edit other people’s content so do not give them the “edit any profile content” permission.

So you’d think we’d be close to done now, but if you now go and try to edit your profile you’ll see there’s a required title field.  Even more annoyingly the only way to get rid of it is to add another module, the Automatic Node Titles module.  Once you install this you go to the profile content type (Administer->Content Types->Profile->Edit again) and you’ll see a section at the top called “Automatic Title Generation.”  Open that and set the option to “Automatically generate the title and hide the title field.”  I don’t see any reason to care what the title will be since it will be used inside another page anyway so I don’t worry about setting any other options.

Now we’ve got it to where it’s reasonable to edit.  You can go fill out the body field (as if it were a bio for example) and save and you’ll see it on your profile.  Unfortunately you’ll also see a bloody “Submitted by X on …” line at the top of it.   Great!  To get rid of that go to Themes->Global Settings and in the upper right hand corner you’ll see a list of content types inside a box labeled “Display post information on.”  Remove Profile and voila!  We’ve managed to make an absolutely boring profile in Drupal with just 10 semi-easy steps.

Now you might be wondering why we went through all that trouble just to get a really bland profile that looks decent.  The reason is because now that we’ve gotten a content profile set up and looking right, we can do the very complex task of making cool custom profiles very easily.  We’ll address that later, but this should at least get you through the frustrating act of getting the initial profile set up.  Let me know if anything needs clarification or if you disagree with anything.

Photo Credit: misteraitch

Categories: Applied Use

Related Posts:

26 responses so far ↓

  • wza | Mar 26, 2009 at 1:37 pm

    so how can u make a user edit his/her own profile info? and can u generate a menu link for the users to do so?

  • Brad | Mar 27, 2009 at 1:44 pm

    wza,

    The easiest way I think is to use the “me” module:

    Me Module

    Which will create menu items for the currently logged in user.

  • josh | Apr 8, 2009 at 4:33 am

    Interesting read. Pretty straight-forward and should help me get started on better profiles.
    Looking forward to your next post about “making cool custom profiles.”

  • Rick | Apr 29, 2009 at 1:29 pm

    After setting this up, my content profile does not show up on the main user account page, it only shows when the user clicks edit and then there is a link to edit the content profile. Is there a way for this to show up on the main user page, am I just missing a setting somewhere? I have it set on content profile page where it says “User page display style” I have set “Display the full content”. Thanks in advance for any advice.

  • Borik | May 5, 2009 at 1:10 pm

    So how can u make a user edit his/her own profile info?

    When i click on edit link i don’t see any of the new fields,
    it shows default Edit Screen, i was hoping to see all the fields.

    Thank you

  • Brad | May 5, 2009 at 2:23 pm

    Both of these questions seem to be relating to the same fact. There is a tab under their profile where they can edit the additional fields, however I agree that it would be nice to have them in the first tab. I will check on how to do that.

  • Shane | May 15, 2009 at 2:53 pm

    Is it just me or does it not display the comments posted to the profile on the “my account” page. It shows it on the profile page. Just trying to figure out how to get it to show up on the “my account” page. Seems to render the node but not the node comments.

  • Andy J | Jun 13, 2009 at 6:14 pm

    Thanks this was useful info. Any plans to write the follow up article? Thanks

  • Brad | Jun 13, 2009 at 9:00 pm

    Andy,

    Yeah I have a few drafts of things I keep meaning to put up on here. I will make a special effort since I’ve been such a slacker.

  • karthick | Jun 15, 2009 at 4:22 am

    Thanks Brad,

    It really helps to have a cutomized multi step registration for different user roles.

  • Kenny S. | Jul 2, 2009 at 5:57 pm

    Great starter article. I was just browsing the web for content profile information since I have a special use case and wanted to throw in a suggestion if I may.

    I prefer to set the Automatic Node Title on my Content Profiles simply because if you don’t, you end up with a ton of nodes in your content list that have the title: “profile” or whatever you have named the content type.

    Typically what I do is set the title to be [author-name] from the Token module. This makes life easier because a username has to be unique. The only rub is if in your in a scenario where the usernames can be changed by the user. In which case, you would want a quick hook_user in a custom module to change the title as the username is changed.

    Thought I’d toss that in. Great site!

  • Brad | Jul 2, 2009 at 6:05 pm

    Kenny,

    That’s an excellent suggestion. I don’t remember actively doing that but it seems to have gotten set up on mine. Thanks for the pointer, I will walk through a setup again to see how it wound up that way and update the post.

  • giozzz | Aug 26, 2009 at 8:27 am

    Hello!!! nice tutorial, very helpful.
    I have a question I hope someone can answer: I want to add a field when a user registers for the first time… I want a user to specify not only a username, email and password, but also another detail… how can I add a field into registration form? Using content_profile..? but how?? hope someone could help! tksssss

  • Steve | Sep 24, 2009 at 8:02 pm

    Thanks for this! I had some trouble getting content profile up and running, but with your tutorial i could get it work! awesome!

  • Sven Aarts | Oct 26, 2009 at 5:58 am

    Tnx for your post.
    I had some problems with custom cck fields not showing up on the profile page but I found out you can configure them to show up on the permissions page.

  • Mittal Patel | Oct 27, 2009 at 3:46 am

    Nice article!!!
    I had done this on my own but now I am struggling to configure profile_setup and pageroute module. If I am taking content profile enabled content type then it doesn’t behave as per my expectations so exploring more to find it out.

    Thanks !!!

  • Marshall | Jan 4, 2010 at 12:52 pm

    I’m having problems with the post information data? I followed the instructions on going to Themes>Global Settings and changed it and also cleared the cache (Performance>Clear Cache), but I’m still getting that ugly post information. Are there any other clean methods for getting rid of this?

    Thanks, your instructions have been very helpful.

  • Darrin Southern | Jan 10, 2010 at 2:12 am

    “The reason is because now that we’ve gotten a content profile set up and looking right, we can do the very complex task of making cool custom profiles very easily. We’ll address that later . . .”

    I’d be very interested in seeing a blog post that explains how to do this part.

    Is it ‘later’ yet 🙂

    Thanks in advance,

  • Jeff Kenner | Jan 12, 2010 at 3:03 am

    Thanks for this easy-to-follow guide. Like everyone else, I can’t wait for the “cool custom profiles” part.

    Cheers!

  • Derek | Feb 15, 2010 at 10:01 pm

    Great post. I had removed Content Profile because I didn’t know about the Automatic Node Title module, but after reading this I put it back on and got everything working exactly the way I wanted. Thanks!

  • Serge | Feb 17, 2010 at 10:30 am

    Hi! thank you for this post!

    Can you suggest a solution,
    I’m updating a website were already exist 200+ users with filled profiles (20+ custom fields). We need to convert them to the profile nodes.
    Is there a module (or code snippet) which converts all data from profiles to appropriate nodes? thank you

  • Jeremy | Feb 23, 2010 at 12:26 pm

    Hi, I’m wondering if you ever got around to doing the theming article you talked about. I’m really interested in finding an easy way to theme the user profile page for content profile. Thanks.

  • Rabe'e Abdelwahab | Apr 28, 2010 at 4:15 am

    thank you very much, those steps i always check whenever i install the content profile module as i never memorized them 🙂

    thanks again

  • Lance | Jun 28, 2010 at 12:57 pm

    I am new to drupal and using it for the first time. I’ve read your tutorial and I am in the process of setting up, roles, permisions, profiles, etc. I have four roles, admin, agent, customer, affiliate. Each one of those roles have multipule users with their own profiles, like a bank account. I am confused with where to start, and which modules to start with. I get lost in all of drupals modules and end up reading all the cool stuff each module can do. can you give me some direction?

  • Brad | Jun 28, 2010 at 6:57 pm

    Lance:

    I haven’t ever implemented that myself but you might check out this module:

    http://drupal.org/project/profile_role

    I’m not sure you want to use Content Profile for what you’re doing. Let me know how it turns out.

  • Steven | Jul 14, 2010 at 9:41 am

    Thank you very much. I’m working on a multi-lingual site but can’t translate prfiles. Since this makes it a CCK I’m open to so much more flexibilty. A colleague recommended this module but d.o. doesn’t have good documentation for it. Very good tutorial.

Leave a Comment