Get current user profile in custom controller (v2025)

How do I get the current user’s profile in a custom controller file?

I tried:

$profile = Profile();

$profile = Container(“user.profile”);

none of these seem to work…

  1. Which version are you using?
  2. You only get the service from container, the $profile should have value, you may check by var_dump().
  3. Where exactly did you add above in the custom controller? What are you trying to achieve? You may post complete code of your controller for discussion.

I figured it out:

if (IsLoggedIn() && !IsSysAdmin()) {
	$userName = $this->security->currentUserName();
	$user = UserRepository()->loadUserByIdentifier($userName);
	$profile = Profile()->setUser($user);
	...

Using v2025.12. Thanks!