Hi there... newbie to drupal & usernode here...
I have a site where I intend users to register and add some info about them, so I think that I should be able to manage it using only usernode (as opposed to the full node profile).
There is only one kind of user easily modeled with simple CCK fields.
Now, I installed usernode and configured the CCK fields of the otherwise "empty" usernode type.
What I'd like to do is to handle everything as close as possible as if the usernode is part of the user profile (and vice-versa).
The hard part is already handled by the module (creating/deleting), but I wonder what is the best way to be able to do the following:
- Whenever a new user self-registers (i.e. when he comes back from his mail with his url to login for the first time), I'd like him to edit his usernode... the best would be to do so within the same page he is entering his password and email (the only thing I did, so far, is to generate a link like
<a href="/usernode">Enter your personal data</a>in user_profile.tpl.php. - I kinda handcafted a node-usernode.tpl.php which allows me to redirect the /usernode to the correct node/XX and if the user viewing the node is the author (owner) of it, it gives a link to change the password, but it'd be great if this would be somehow integrated (see below).
Is there a better way to do this?
<?php
// If the guy is not logged in, I send him to /user to login/register
// THIS DOESN'T WORK :-(
if ($GLOBALS['user']->uid == 0) {
drupal_goto('/user');
return;
}
// Check whether the logged user is the owner of this page
if ($GLOBALS['user']->uid == $uid) {
$its_me = true;
} else {
$its_me = false;
}
// BABY: Redirect to actual node in order to have the 'edit' option
// http://drupal.org/node/113196#comment-185980
if (arg(0) == 'usernode') {
drupal_goto('node/'. $nid);
}
?>
<!-- from original node.tpl.php -->
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
<?php print $picture ?>
<?php if ($page == 0): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<div class="content">
<?php print $content ?>
</div>
<!-- if I'm the owner, show me where to change password & e-mail -->
<?php if ($its_me): ?>
<a href="/user/<?php print $uid ?>/edit">Change password and e-mail</a>
<?php endif; ?>
<div class="clear-block clear">
<div class="meta">
<?php if ($taxonomy): ?>
<div class="terms"><?php print $terms ?></div>
<?php endif;?>
</div>
<?php if ($links): ?>
<div class="links"><?php print $links; ?></div>
<?php endif; ?>
</div>
<?php if ($submitted): ?>
<span class="submitted"><?php print t('!date — !username', array('!username' => theme('username', $node), '!date' => format_date($node->created))); ?></span>
<?php endif; ?>
</div>
?>TIA

Comments
Bio.module
I've been beating this drum for a while, but bio.module does what you want - it associates a node type (by default the "bio" type, but you can change this to whatever you want) with the user's profile page. You can even set it to "override" the profile page entirely. Very useful.
http://drupal.org/project/bio
Nodeprofile, too
Nodeprofile does this, too, except for the overriding the entire page part. Though that's coming as a bonus as per:
http://drupal.org/node/140592
Michelle
Using bio (for now)
Thank you all for your comments...
I finally installed bio (with the patch) for this little project... I think it'll be less of a headache... anyway, I'll have another project RSN that is probably going to use node profiles extensively... this week's release looks very promising and having fago around answering most every request for support is certainly a bonus... I only hope I were more fluent with drupal in general.
Regards.
Mariano Absatz - el Baby
--
Mariano Absatz - el Baby
They are very similar
I wavered between bio and nodeprofile. I think they are both quite capable. I ended up deciding on nodeprofile but I don't think bio is a bad choice, either. The nice thing is, since you can set the content type for both of them, you can easily switch between the two should you change your mind without having to port data.
Michelle
Switching
RE: "you can easily switch between the two should you change your mind without having to port data" --
Exactly!
This is why in the DrupalEd profile, I chose to use bio instead of usernode/nodeprofile -- down the road, I think that usernode/nodeprofile/nodefamily has a lot more potential for both profiles and node relations than bio -- but, for right now, bio is lightweight and gets the job done, which translates into an easier upgrade path/transition to a more robust solution later.
Cheers,
Bill
FunnyMonkey
bio - copy user->name into bio->title
FWIW,
I'm doing just fine with bio for this small project... I followed Bill's advice and applied the 'permissions' patch from http://drupal.org/node/131321#comment-230450 .
One thing I wanted to do was to copy the user's email from the user profile into the bio node, which I was able to do with http://drupal.org/node/135045#comment-226885 .
But the other thing I wanted was to copy (when the user auto-created its own bio node) the username into the bio's title (which I, and I think other people too) use for the user's name.
Since CCK doesn't allow you to put a default value (let alone php generated) in to a node's title, I hacked the bio module in order to do this automatically. I took an additional 20 minutes to make this optional in the bio module settings. If you want to take a look the patch is attached to http://drupal.org/node/141392
Regards.
Mariano Absatz - el Baby
--
Mariano Absatz - el Baby
RE the Bio Title -- prepopulate?
The prepopulate module -- http://drupal.org/project/prepopulate -- might get this done for you -- we've used it with to prepopulate nids with nodereferences, and it worked well there
Cheers,
Bill
FunnyMonkey
Titles
Have a look at http://drupal.org/project/auto_nodetitle
Michelle
should've asked before...
Well,
it seems auto_nodetitle was (almost) exactly what I needed... I just tried and the only thing I liked better with my approach was that the auto loading of the title on node creation is associated with the title hiding, since I don't allow users to change their usenames (in the user profile) but might like to allow them to change the shown name/surname (in the user bio)... anyway, I'd saved some work by asking if there was some way to do what I wanted before doing it myself :-)
Regards.
--
Mariano Absatz - el Baby
--
Mariano Absatz - el Baby
Bio module is useful
Second this on the bio module -- just be sure to apply the patch from this issue: http://drupal.org/node/131321 -- the patch is posted in response 4 --
Cheers,
Bill
FunnyMonkey