Current User: Guest
Please consider registering


Register? | Lost Your Password?

Search Forums:


 






Minimum search word length is 3 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

User name for greeting

Unresolved
UserPost

5:09 pm
March 9, 2010


giuseppe

Italy

Member

posts 6

 
1

Hi Mr. Jeremy.
In my blog (at header) I have the code for the greeting and the current time. I would like to include (after the initial greeting) the name's user if he is logged or just 'guest' if not.
Can you help me?. Thanks!.

10:40 pm
March 9, 2010


Jeremy Clark

Admin

posts 484

 
2

Hey Giuseppe
I'm going to look into a way to pull the last logged in user from the cookie that wordpress sets, but for now you can use this to get all the logged in user info.

<?php
global $user_ID;
get_currentuserinfo();
if ($user_ID){
echo 'Hello ' . $current_user->user_login ; //is the user login name
echo 'Hello ' . $current_user->display_name; //is the display name set by the user.
} else {
echo "Hello Guest";
?>

You can choose either the login name or display name, display name might be better if they have set it up if not then it will default back to the user login. I'll let you know if I find out the cookie method.

Like Techozoic?
Rate it here or donate securely with PayPal to support my further development of Techozoic.

1:32 am
March 10, 2010


giuseppe

Italy

Member

posts 6

 
3

Hi Mr. Jeremy, thanks for your reply.
I miss something, because inserting the code, it generates an error.
This is my original code:
function aggiorna() {

var mesi = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
var nomeGiorno = new Array('Domenica', 'Lunedi', 'Martedi', 'Mercoledi', 'Giovedi', 'Venerdi', 'Sabato');

Data = new Date()
Giorno = Data.getDate()
Mese = Data.getMonth()
Anno = Data.getFullYear()
Ore = Data.getHours()
Minuti = Data.getMinutes()
Secondi = Data.getSeconds()

if ((Ore > 5) && (Ore 12) && (Ore 17) && (Ore 21) Saluto = "Buona notte"

if (Ore < 6) Saluto = "Buona notte"

if (Ore < 10) Ore = "0" + Ore

if (Minuti < 10) Minuti = "0" + Minuti

if (Secondi < 10) Secondi = "0" + Secondi

messaggio = Saluto + Confused", sono le ore " + Ore + ":" + Minuti + ":" + Secondi + " di " + nomeGiorno[Data.getDay()] + ", " + Giorno + " " + mesi[Mese] + " " + Anno

if(!document.layers){
aggsec = setTimeout("aggiorna();",1000);}

if (document.getElementById){
document.getElementById('clock').innerHTML=messaggio;}

else if (document.all){
document.all.clock.innerHTML=messaggio;}

else if(document.layers){
document.write(messaggio);}
}
aggiorna();

Where is the smile I like to have the userId or the name or "Ospite".

4:43 pm
March 10, 2010


Jeremy Clark

Admin

posts 484

 
4

Post edited 11:39 am – March 12, 2010 by Jeremy Clark


Sorry I think I see the problem give this code a try.

<?php
global $user_ID;
global $current_user;
get_currentuserinfo();
if ($user_ID){
echo 'Hello ' . $current_user->user_login ; //is the user login name
echo 'Hello ' . $current_user->display_name; //is the display name set by the user.
} else {
echo "Hello Guest";
}
?>

Like Techozoic?
Rate it here or donate securely with PayPal to support my further development of Techozoic.

7:41 pm
March 10, 2010


giuseppe

Italy

Member

posts 6

 
5

Post edited 1:46 am – March 11, 2010 by giuseppe


Hi Mr. Jeremy
Your code is Ok… It returnes exactly the user_name and the display_name (adding, after the else statement, the brace), but unfortunately I don't know how to insert it in my function code that I wrote in my last post and, when I try, there is always some error.
Please… If you can, ultimately, I would like that, after the initial greeting, being shown the real name of the logged user (if declared at the time of registration) or in the absence of that, the user_display or (and if the guest is not logged) only Guest.
Thank you and good night.


Reply to Topic:
User name for greeting

Please include the version number of theme that your asking about. As well as a link to the website where the problem is happening if applicable. Thank you.

Guest Name (Required):

Guest Email (Required):

HTML Editor
Smileys
Confused Cool Cry Embarassed Frown Kiss Laugh Smile Surprised Wink Yell
Post New Reply

Guest URL (required)

Math Required!
What is the sum of:
9 + 6
   


Unresolved


About the Jeremy Clark – TechNet.com Forum

Forum Timezone: America/New_York

Most Users Ever Online: 66

Currently Online:
12 Guests

Currently Browsing this Topic:
1 Guest

Forum Stats:

Groups: 2
Forums: 3
Topics: 359
Posts: 1268

Membership:

There are 307 Members
There have been 120 Guests

There is 1 Admin
There is 1 Moderator

Top Posters:

BartC – 107
demoondoggie – 23
Heather – 21
SarahM – 15
mpromp2 – 15
Monica – 15

Recent New Members: livewise, mpromp2, kevin, cbegg50, kismetconsulting, AdminKim