I have a node where I want to take some fields from a user's profile and their email addres. The workflow happens so that first the user registers, then submits their event. I don't want them to have to fill-in their fields again like name, email, and website. Any tips on getting these in as computed fields? Also, the field "website" is optional, so what happens if they don't fill that in?

Comments

wrunt’s picture

In your computed code try something like this:

global $user;
$node_field[0]['value'] = $user->name;

To get the email, use $user->mail instead of $user->name.

Lisa Williams’s picture

This works great -- thanks. One question: when we display the username, is there a way to wrap the username in a link to the user's profile?

Christefano-oldaccount’s picture

Just a guess (I haven't yet used Computed Field in a project), but try $node_field[0]['value'] = theme($user->name);

Lisa Williams’s picture

Title: User name and email » User name and email -- make it a link?

Thanks, I'll try it!

Lisa Williams’s picture

....mmm, nope, didn't work for me. Thanks for the suggestion -- every experiment gets me closer to success, right?

Lisa Williams’s picture

Hmm...this post may explain why urls aren't appearing in computed fields:

HI all,I have a problem with rendering HTML code in Computed Fields. The reason I have to use computed fields is to create a url with a sitename so the computed field generates the HTML code for this based on two other fields (one with the url and one with the sitename). However when I try using the computed field it just writes the HTML as text - and for computed fields you cannot set the text type to Filtered Text, which in other cases should do the trick..Anyone have a solution for this?Thanks,
jacknoir

Okay, it seems to me that what I'm trying to do -- get things like a link to the user's usernode, list of recent blog entries, etc. are things that many people are doing by fiddling with their theme. If it's true, I think there's good reason to support a CCK field that allows site admins to make fields like "link to username" "show user buddylist" etc. because it would make the nodetype more portable -- no searching around to see which parts are part of the theme and which are fields in CCK if you change your theme, or want to allow others to reuse what you've done.

Moonshine’s picture

Status: Active » Closed (fixed)

Closing out old Drupal 4.7 issues, as it is no longer a supported release.