How to use conditional not to print a field if empty in user profile? As in node.tpl.php, I would like in user-profile.tpl.php to test if a field is empty or not to show my html. 

I tried it :

&lt;?php if (!empty($user_profile['field_myfield'])): ?&gt;
&lt;?php print render($user_profile['field_myfield']); ?&gt;
&lt;?php endif; ?&gt;


But it does not work.

Have you the solution?
Have you thought of using Entity Metadata Wrappers?

You can wrap the user profile using $user_profile_wrapper = entity_metadata_wrapper('user', $user_profile);, and then you can find out if the field has a value with:

if (isset($user_profile_wrapper-&gt;field_myfield)) {}


This should tell you if the user profile HAS the field, and then you might use:

$value = $user_profile_wrapper-&gt;field_myfleid-&gt;value();


to actually get the value and test if it's empty or not.

Sources:


https://www.drupal.org/documentation/entity-metadata-wrappers
Checking for existence for a field on an an entity_metadata_wrapper