WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to say 'howdy, $user_id' (23 posts)

  1. drabiej
    Member
    Posted 8 years ago #

    Basically I'd like to duplicate the Admin panel functionality. If someone is logged, I'd like them to see a "Hello, $user_id" where $user_id is their nickname.

    I looked through the Template Tags but don't see anything that will do it -- anyone point me the right way? :)

  2. twat
    Member
    Posted 8 years ago #

    Hi,

    I think this should work:

    <?php printf(__('Hello, <strong>%s</strong>.'), $user_identity) ?>

    (piked it straight off the wp-admin/admin-header.php)

    Kat, the Twat

  3. drabiej
    Member
    Posted 8 years ago #

    Unfortunately $user_identity isn't defined outside of wp-admin :-/

  4. skippy
    Member
    Posted 8 years ago #

    global $user_identity;
    get_currentuserdata();
    if ($user_identity) { echo "Hi $user_identity!"; }

  5. vkaryl
    Member
    Posted 8 years ago #

    Oh good, with this info I should be able to stop my own blog admin pages from saying "howdy" to me..... WHAT a silly thing to have implemented.... nice for the OP, the global one though!

  6. Kafkaesqui

    Posted 8 years ago #

    Hey, I like WordPress' folksy welcome. Don't see what's wrong here...

  7. vkaryl
    Member
    Posted 8 years ago #

    Each to her own.... I know who I am, I don't need some program saying hello to me to remind me....

  8. Kafkaesqui

    Posted 8 years ago #

    "I don't need some program saying hello to me to remind me...."

    Considering I have 6 different logins on a couple setups, yeah it helps to be reminded.

    Her? ;)

  9. vkaryl
    Member
    Posted 8 years ago #

    I'm a her. She. Whatever.... each to "hisser" own (to rob a word from Jo Clayton....)

  10. drabiej
    Member
    Posted 8 years ago #

    danke mucho for the help :)

  11. kickass
    Member
    Posted 8 years ago #

    Geez, V, can't ya go anywhere without starting an argument? And all because your user admin is trying to be FRIENDLY! sheesh!

  12. vkaryl
    Member
    Posted 8 years ago #

    Hmph. There are better ways of being friendly.... besides, I was just happy to have someone point out where to find the silly thing.

  13. Kafkaesqui

    Posted 8 years ago #

    There was an argument? And I missed it? While being in the middle of it?

    Man, I'm good.

  14. vkaryl
    Member
    Posted 8 years ago #

    I TOLD you you were good the other day.... you missed that too huh?

    *snicker*

  15. Kafkaesqui

    Posted 8 years ago #

    No, I just didn't believe it. After all, the word is you're always starting arguments, so...

  16. vkaryl
    Member
    Posted 8 years ago #

    *rolls eyes* Well, you just can't believe everything you hear (*whispers* especially if it's kickass saying it....)

    *virtuously wearing halo* I only start arguments when there's a 100% chance of either: A. winning; or B. annoying someone important beyond the point of no return.

  17. kickass
    Member
    Posted 8 years ago #

    Geez, V, I was only repeating what I heard from K . . . um . . . nevermind.

  18. vkaryl
    Member
    Posted 8 years ago #

    They're all out to get me. I maintain my innocence. I will go to the stake wearing white sackcloth and ashes, my hair.... um. No, that was some movie or the other, wasn't it?

    Er. Well. Maybe we better just let this die a natural death, hmmm?

  19. Dortamur
    Member
    Posted 8 years ago #

    I got an error using:
    get_currentuserdata();
    ...but after some rummaging, tried this, and it worked:
    get_currentuserinfo();

    (I'm using wp 1.5.2 at the moment).

  20. sremington
    Member
    Posted 8 years ago #

    This feature looks cool. So what was the code and what files do I edit??

  21. vkaryl
    Member
    Posted 8 years ago #

    See Skippy's post above for the code, and I believe you'd edit it into header.php - at least that would seem to make sense. If that doesn't quite get it, then perhaps just before the loop in index.php, single.php, etc.

  22. bubazoo
    Member
    Posted 7 years ago #

    you can get away with not using

    global $user_identity;
    get_currentuserinfo();

    if your template just has a single index.php file (meaning no header.php, sidebar.php, footer.php etc)

    For instance, the simple-green theme I didn't have to use global, or get_currentuserinfo();

    however, with templates that DO have them split up in multiple files (I just found this out reciently after trying to split the simple-green theme up into multiple files) you HAVE to use global.

    however, get_currentuserinfo(); isn't needed either way. not sure why that is... In fact, I used global inside of sidebar.php, just before using $user_identity, and it worked just fine. I didn't have to put global in header.php or index.php, I'm assuming the reason is because globals are no longer registered inside multiple includes (shrugs) thats just a guess though.

  23. bubazoo
    Member
    Posted 7 years ago #

    but I 'HAD" to use global somewhere in my templates, if my templates have a header, index. sidebar, and footer, otherwise $user_ID, $user_identity, etc etc have no values, so each variable you want to use, you have to setup a global statement just before it.

    but i don't have to use global if the template is just within an index.php (no header or sidebar in the template)

    weird eh?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.