I am sure this is treated somewhere on this website, but I couldn't find it... so forgive me for posing an obvious question. Bear in mind that I don't know much - if anything - about MySQL and PHP.

My problem is that I cannot figure out how to create a hyperlink to a URL involving the user ID of the logged in member. In the standard setup the link to 'my account' or 'my blog' does this: it replaces the $uid in the URL ./q=blog/$uid with the actual ID of the member, for example. But just using variables like $uid in the link doesn't work,.. so how do I do this?

Thanks in advance

Comments

sillygwailo’s picture

Where do you need the link? You can do it in PHP, whether in the theme, a block or a PHP post. (It won't show up, I don't think, in the RSS feed if you use the following in a PHP post.)

global $user;
print l("your blog", "blog/" . $user->uid);

That should create a link to a user's blog with the link text "your blog" (you can change that to whatever you want), and use the URL alias if there is one.

(Username formerly my full name, Richard Eriksson.)

Timos-2’s picture

Thanks! I don't need to put it in a feed, so this works great!

Thanks again!

fourmi4x’s picture

Just so that the default URL is already in the link (I was getting http:///1 !!) :

global $user;
print( '<a href="/user/'. $user->uid.'" >My account</a>' );