How to fetch the status of profile flag? I have a profile flag called "keep my photos private" using which user can flag his content and can keep it private. I want to fetch the status of the flag by the specific user. I have tried php code but its not working.  

global $user;
$user_uid=arg(1);
$flag=flag_get_flag('keep_photos_private');
print "Flag Name : ".$flag-&gt;title;
print "User : ".$user_uid;
if($flag-&gt;is_flagged($user_uid)) { 
  print "flagged";
}
else {
  print "not flagged";
}


Is my code wrong?
I worked with Profile2 a while ago and it was not a joy for me. I remember having to implement a hook_user_insert and creating the profile right there and there as the profile was only created after a user saved a new profile. So if you have a flag on it and flag it without saving the profile it might just go lost as the profile does not really exist yet.