use Drupal\node\Entity\Node;
use Drupal\Core\Form\FormStateInterface;

/**
* Implements hook_form_alter() on behalf of tm_sketch.module.
*/
function YOUR-MODULE-NAEM_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'your form id') {
$nid = \Drupal::request()->query->get('nid');
$node = is_numeric($nid) ? Node::load($nid) : NULL;
$form['og_audience']['widget'][0]['target_id']['#default_value'] = $node;
}
}

Comments

VM’s picture

per https://www.drupal.org/node/643758 please edit your post and move it to the 'post installation' forum. Thank you.