Implements hook_preprocess_HOOK() for block.html.twig.
function user_preprocess_block(&$variables) {
if ($variables['configuration']['module'] == 'user') {
switch ($variables['elements']['#plugin_id']) {
case 'user_login_block':
$variables['attributes']['role'] = 'form';
break;
case 'user_new_block':
$variables['attributes']['role'] = 'complementary';
break;
case 'user_online_block':
$variables['attributes']['role'] = 'complementary';
break;
}
}
}