I am basically trying to do what described in How can I let anonymous users view user profiles by role? in Drupal 8. User profiles should only be visible to anonymous users only if those profiles are for users having a certain role; all the other user profiles should not be accessible to anonymous.
The answer there suggests using hook_user_view()
, but it appears that hook has been removed in Drupal 8. Is there a different/correct way to do this now?