I used hook_theme_suggestions_HOOK_alter
:
function MYTHEME_theme_suggestions_user_alter(&$suggestions, $vars, $hook) {
// Define the view mode.
$mode = $vars['elements']['#view_mode'];
// Create a theme hook suggestion which has the view mode name in it.
$suggestions[] = 'user__' . $mode;
}
Now I can work with user--full.html.twig
and user--compact.html.twig
But I have a role editor
and I want to user--compact--editor.html.twig
to be picked up. How can I add a template suggestion based on user roles?