Blog

The Haycroft Media Blog covers all aspects of website design and development from the web browsers being used through to the standards that govern the world wide web. As a website design and development company, it is imperative that we keep abreast of all the latest news and happenings in our field, and here we present the major stories along with tutorials, tips and other web-programming related items.

Displaying user data in your WordPress theme

The last time I needed to display user data was for the Press Stick website. For their site, they wanted the user to be greeted with a personalised message on logging in.

The message for the Press Stick site was:
“hi [NAME] from [MAGAZINE]. welcome back to the press-stick sourcing portal. we look forward to showing you the new and exciting products available to you.”

For the purpose’s of this site, we tweaked the standard WordPress user data so that the user’s magazine name would be stored in the ‘Nickname’ field. To return the message above, we simply insert the following:

<?php
get_currentuserinfo();
$name = $current_user->user_firstname.' '.$current_user->user_lastname;
$magazine = $current_user->nickname;

echo '<p class="intro">hi '.$name.' from '.$magazine.'. 'welcome back to the press-stick sourcing portal. we look forward to showing you the new and exciting products available to you.</p>';
?>
[ Back ]
Posted on Tuesday, November 17th, 2009, Filed under Content Management System (CMS), php, wordpress