Easy way to put user's avatar on any page

Forum
Last Post
Threads / Messages

Derpstra

Seamstress!
Member
Joined
Aug 13, 2012
Messages
26
Points
0
Location
Seattle, WA/Charlotte, NC
Mysidian Dollar
3,434
Being a very lazy person, I like to make my scripts as simple as possible. Usually I achieve this by messing around with the functions. Today I made an easy one that allows you to put the user's avatar wherever you want!

First, add this function to the page functions/functions_users.php:
PHP:
function usernametoavatar($name){
    $row = $GLOBALS['adopts']->select("users_profile", array("username", "avatar"), "username='{$name}'")->fetchObject();
    return $row->avatar;
}

Now, on whatever page you want to add their avatar to, paste this anywhere on the page before $article_title:
PHP:
$avatar = usernametoavatar($username);

Then, in your $article_content, place this wherever you want the avatar to show up:
PHP:
<img src='{$avatar}' />

Ta da! They will see their own avatar! :smile:
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,122
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top