how to retrieve the currently logged in users email address.
Published by drupal_developer on February 19th, 2009 in Drupal Modules
Does anyone have any idea how to retrieve the currently logged in users email address.
Attempted various methods such as;
if ( $user->email ) {
echo $user->email;
}
but to no avail.
any suggestions?
rightchoice2c_me on February 20th 2009
If you mean the get the current logged in user's mail-id then try this
global $user;
print $user->mail
else u want to get the email-ids of all logged-in users then try this
$interval = time() - variable_get('user_block_seconds_online', 900);
$authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, u.mail as mail, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
while ($account = db_fetch_object($authenticated_users)) {
echo $account->mail . '
';
}