How can I access fields values inside profile2 main profile? Only on edit main profile page? I try to hide a field on profile2 edit page based on another value. Code is from my template.php
function my_theme_form_profile2_edit_main_form_alter
and then calling
global $user;
$profile = profile2_load_by_user($user->uid, 'main');
$checkbox1 = $profile->field_checkbox_admin1['und'][0]['value'];
The problem is that profile variable is not accessible if all of the fields in profile are empty. dpm($profile) shows nothing and I get undefined variable error.