OK, this may be harder to understand if I explain it in general terms, so here's what I'm specifically trying to do: I want to be able to create a link in a story that says something like "Visit the [my account] section to update your profile!", and I want [my account] to link straight to the profile edit page at http://www.mysiteURL.org/?q=user/[users's id #]/edit.

So my question is how to create links that use the current user's id #? Obviously static links are really easy, e.g.

http://www.mysiteURL.org/?q=user/1/edit
http://www.mysiteURL.org/?q=user/231/edit
http://www.mysiteURL.org/?q=user/125/edit
etc.

but the point is that there is no way I can know the user's # ahead of time. So is there some way to create links that use the current user's id #? Thanks.

Comments

DriesK’s picture

and then you could do something like this:

global $user;
if ($user->uid) {
  print l('Update your profile', 'user/'.$user->uid.'/edit');
}

The if-test makes sure the link is only displayed to logged in users (it doesn't make sense to redirect anonymous users to user/0/edit...

sheepy898’s picture

Works great.

Techinica’s picture

And what if I want to do this as on of my primary links?

wheresmycookie’s picture

http://drupal.org/project/me

kind of late i know hehe