I am trying to get yshout (a shoutbox) working in my WordPress blog. I want the logged in members to be able to chat and have their member names used to identify their chat postings.
To do this I need to change this line of code in yshout's preferences.php:
$overrideNickname = null;
into something like this:
$overrideNickname = ?????;
where the ????? represents a php variable containing the logged in member's name.
yshout's preferences.php contains this advice:
// If you want to change the nickname, the line below is the one to modify.
// Simply set $overrideNickname to whatever variable you want to appear as the nickname,
// or leave it null to use the set nicknames.
$overrideNickname = null;
When I wasn't able to discover what to substitute for "null", I emailed yshout's creator and received the following instructions:
I'm not too familiar with Wordpress, but you need to find out how to get the
nickname of the current user into a php variable. From there, you simply set
$overrideNickname to that value, and hide the nickname input via CSS
so that people don't see it.
I tried to follow up but he doesn't appear to be available and unfortunately I'm somewhat pressed for time.
I am able to display logged in usernames elsewhere on my blog using a plugin called WP-UserOnline.
Here is my question: what variable is there in WP-UserOnline's code (below) that I can substitute for "null" (in $overrideNickname = null; ) and how must I format it?
TIA immensely!
// Print Member Name
if($members) {
$temp_member = ';
if(!function_exists('get_totalposts')) {
foreach($members as $member) {
$temp_member .= $member.$separator_members_browsingpage;
}
} else {
foreach($members as $member) {
$temp_member .= '
'.
$member.''.$separator_members_browsingpage;
}
}
$template_browsingpage = str_replace('%USERONLINE_MEMBER_NAMES%',
substr($temp_member, 0, -strlen($separator_members_browsingpage)),
$template_browsingpage);
} else {
$template_browsingpage = str_replace('%USERONLINE_MEMBER_NAMES%',
', $template_browsingpage);
}
(Incidentally, via first result googling "wordpress how to get username of current user")
posted by juv3nal at 11:45 PM on May 4, 2008