6

I've added a few custom user fields which users complete when registering.

What is the simplest approach to show these fields when viewing content that user has created?

For example, when viewing a blog entry I can see the 'submitted by..' and their name. I would like to use my custom user fields to expand that summary.

I've got no problem using views, or creating/modifying the theme etc, but I'd like some guidance on the easiest approach before I start out. (It's too easy to hack away on one approach in Drupal when there's a much easier solution!)

4

I would do this with two steps.

  1. Create a theme function that will take the user object and render what you want to render instead of submitted by username.
  2. Alter the node template or use the preprocess_node and get the user from the node $node->uid and use hour theme function to replace the default submitted by with your custom value.

Doing it like this should be quick, easy and simple.

  • This sounds like a very good blend of simplicity and flexibility and it's an approach I wouldn't have considered. – Garry Jun 6 '11 at 18:25
4

Ok, I'm only using drupal 6 but I think these answers can lead you to a solution:

  1. With the core profile module there is a block "Author information"
  2. You can use the Author Pane module but it doesn't have a stable release for D7 yet.
  3. You can use views to build an author block:

If you're using profile from core:

Create a user view
Set the argument to User: uid
Choose "Provides default argument" set to "User ID from URL" and check "Also look for a node and use the node author"
Add your user profile fields.

If you use Content Profile

Create a node view
Set the argument to Node: Nid
Choose "Provides default argument" set to "Node ID from URL"
Create a relationships to retrieve the content profile
Add your content profile fields.

  • Looks like Profile2 has replaced Content Profile in D7, but it looks interesting! The issue I'm having when using views is getting the fields to appear in a single node view, but that's for a separate question :-) I'll give the Profile2 module a go.. – Garry Jun 6 '11 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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