Code snippet that can be used to set user status to blocked by default in drupal 8.
<?php
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_alter().
*/
function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'user_register_form'){
if (isset($form['account']['status'])){
$form['account']['status']['#default_value'] = 0;
// by default default_value = 1
// $form['account']['status']['#default_value'] = 1;
}
}
}