title: How to load User Profile Type in Drupal 8?
body: <p>I would like to load user profile module data by user id:</p>
  
  <blockquote>
    <p>Code:</p>
  </blockquote>
  
  <pre><code>$profile_type = 'my_profile';
  $user_id = 1;
  $current_user = User::load($user_id);
  $active_profile = $this-&gt;entityTypeManager()-&gt;getStorage('profile')-&gt;loadByUser($current_user, $profile_type);
  
  print_r($active_profile);
  </code></pre>
  
  <p>But, It will return following error.</p>
  
  <blockquote>
    <p>Error:</p>
  </blockquote>
  
  <pre><code>The website encountered an unexpected error. Please try again later.
  Recoverable fatal error: Argument 1 passed to Drupal\profile\ProfileStorage::loadByUser() must implement interface Drupal\Core\Session\AccountInterface, null given, called in C:\xampp\htdocs\catchow\htdocs\modules\custom\catchow_registration_contactlab\src\Controller\CatchowRegistrationContactlabController.php on line 122 and defined in Drupal\profile\ProfileStorage-&gt;loadByUser() (line 16 of modules\contrib\profile\src\ProfileStorage.php).
  Drupal\profile\ProfileStorage-&gt;loadByUser(NULL, 'authenticated_user') (Line: 122)
  </code></pre>