Recommended Drupal API for developing User profile template.

Drupal content management System is a large framework with thousands of API developers can leverage when developing applications, because of drupal developers creativity, we can actually use different approach and API to achieve similar result.
However, using some approach when developing user profile page might expose your drupal application to some security vulnerabilities, making your drupal user profile page a loop hole for hackers.
What you will learn
1. You will learn some recommended API, I often use to build clients user profile page.
2. Practical use cases of those API.
3. Reasons why you should stop using some API’s in your user profile template

I’ll start by showing you features we want to build and how you can leverage drupal API for your user profile template page
1. Profile picture
2. Embed views
3. Show edit link for authorized users
4. Print some custom fields
Disclaimer
I’m not a certified drupal developer but I have spent 4 years building enterprise application with drupal, however I stand to be corrected if you observed any issue when using my approach
Requirements
1. Drupal 7 installed
2. Devel module installed and enabled
3. Comfortable working with PHP and drupal 7 template
Okay, let’s dive IN….
Feature 1; Profile picture
HTML mark-up
<a href=”profile/edit” style=”background-image: url(‘.image/profile,jpeg’);”></a>
According to the markup, the profile picture must be clickable which will redirect to user’s edit page and the picture must be in background.
1 $account = user_load(arg(1));2 $profile_image= file_create_url($account->picture->uri); ?>3 <a href="./?q=user/<?php print $account->uid ?>/edit" style="background-image: url('<?php print $profile_image; ?>');"></a>
Line 1 : The first API is USER_load(arg(1)) which loads all the present user’s profile details in to $account variable
Line 2: I used FILE_CREATE_ULR() which as an argument of $account->picture->uri this loads the full URL of the account picture
Line 3: the HTML that prints out the user profile.
Feature 2 : EMBED VIEWS
I wanted to list properties uploaded my USER, I have already designed my views to do that, so simply calling my views embed api
<?php print views_embed_view('recent_blog_entries',$display_id = 'default'); ?>Feature 3; USER EDIT ACCESS
Since I have removed the edit tab in page — user.tpl.php I have to manually write the edit link ( I did remove the tab to have absolute control on user profile template layout). I hope you can figure how to remove tabs using page — user.tpl.php template override.
<?phpif(user_edit_access($account) == TRUE): ?><a href="./?q=user/<?php print $account->uid ?>/edit">Profile settings</a><?php endif; ?>
User edit access comes in handy, which will only print Profile settings link to authorized user i.e user that have permission in editing the account mostly admin and the user
Feature 4; Print some custom fields
Generally, there are two API’s that can get the job done, but I’ll prefer to go with the inbuilt $user_profile variable
<?php print $user_profile['field_bio'][0]['#markup'];?>Like i said earlier, there are different ways to building and styling drupal user profile template, but i have found the above API to be handy and often used when developing user profile.
I hope you got some stuff, if you’ve built custom drupal user profile template before and you love to share some insights and your preferred API, kindly tell me in the comment box or mention me on twitter @dapseen