How to Display a Drupal Username
Open-source Web content management systems have become a popular method of building websites. Drupal is one of the most widely-used open-source content management systems available. It is used for building websites of all kinds, from smaller ones consisting of a few pages to bigger, dynamic websites used for larger companies and corporations. By default, a username in Drupal is not displayed on the front-end of the website. Getting the username to show up requires some knowledge of the PHP programming language.
Instructions
-
-
1
Log into your website's FTP client and navigate to the directory containing the page in which you would like to have usernames displayed. If you would like them displayed in your index page for example, this will be located in your root or public directory.
-
2
Download a copy of the page to your local hard drive.
-
-
3
Open the page using a text editor, such as Notepad or WordPad for instance. Enter the following PHP code somewhere at the top of the page (first two lines preferably):
<? global $user; ?>
-
4
Enter the following PHP code in the exact position you wish for the username to be displayed:
<?php
print $user->name
?>
Save the file.
-
5
Log back into your website's FTP account and navigate again to the directory containing the page in which you would like to display usernames. Upload the file you just edited, replacing the original one. Navigate to that page using a Web browser. You should now see the logged-in username displayed on the page.
-
1
References
Resources
- Photo Credit Photos.com/Photos.com/Getty Images