PHP code for drupal

Niaina - November 12, 2008 - 06:59

Hi all!

Please! Do someone have idea of the PHP code for having the current user in Drupal!

I have done that by using the view and block and it work well, but i want to have also the code for doing that by using PHP

Thanks alt for your help!

Use $user global variable

sikhone - November 12, 2008 - 07:19

<?php

global $user;
print_r($user) ;..............

above code will select current logged in user please look global variable at
http://api.drupal.org/api/global/user

Thanks.......

global $user

Niaina - November 19, 2008 - 11:46

Thanks a lot Sikhone for your help.

I tried with the global variable that you gave then i did likethis because i want to have the full name of the current user after the word Welcome then i did like this :

WELCOME

<?php
global $user; print $user->name;
?>

But that code print just the current user login!

So if you can please what is the code if i want to have the full name (the full name in the Profile field), of the current user?
Am new and don't know well the PHP code. So all of you suggestion are welcome!

Thanks in advance!

Niaina

 
 

Drupal is a registered trademark of Dries Buytaert.