/**
* Implements hook_ENTITY_TYPE_view().
*/
function my_module_user_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($display->getComponent('my_block')) {
$block = \Drupal::service('plugin.manager.block')->createInstanc