Author Topic: How i get a current user ID ?  (Read 3774 times)

0 Members and 1 Guest are viewing this topic.

Offline Yan

  • Pre-Newbie
  • Posts: 7
    • View Profile
How i get a current user ID ?
« on: December 20, 2009, 12:59:24 PM »
I need to get current user ID, and paste it to template like member.php?id=$current_user_id

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How i get a current user ID ?
« Reply #1 on: December 20, 2009, 06:36:42 PM »
Since I don't know what you are trying to do, and because no links should be constructed in template itself, without first parsed through $site_sess->url() function, I'd suggest use this in the template:
Code: [Select]
<a href="<?php
global $site_sess$user_info$user_table_fields;
echo 
$site_sess->url(ROOT_PATH."member.php?".URL_USER_ID."=".$user_info[$user_table_fields['user_id']];
?>
">link text</a>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Yan

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: How i get a current user ID ?
« Reply #2 on: December 20, 2009, 09:34:46 PM »
Thanks, its works  :D

One more questions. I need a show some content only for admin
Something like this:

<if current user =admin>
content
</if>

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How i get a current user ID ?
« Reply #3 on: December 20, 2009, 09:54:38 PM »
{if is_admin}   {endif is_admin}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)