Render the User creation form on another page I have a Views page and I want to insert the user creation form as found in /admin/people/create into the Views page header. I know people frown upon the PHP filter, but I just need to output the user registration form, which is at most 2 lines of php code vs having to make a module just for that. Unless there is a better way?

I know drupal_get_form() has been replaced from the form builder in Drupal 8, and the Drupal 8 equivalent of drupal_get_form() is, for example, $form = \Drupal::formBuilder()-&gt;getForm(Drupal\user\Form\UserLoginForm::class);.

But how do I get the form name or ID? How do I put it in that example? Do I just inspect the form and grab the form ID?



I tried the following code, but I nothing gets returned. What could I be missing? 

$form = \Drupal::formBuilder()-&gt;getForm(Drupal\user\Form\user_register_form::class);
drupal_render($form);
You could use the Form Block module and place it before/above your view. 


  Enables the presentation of user registration, site wide contact, or
  node creation forms in blocks. This is particularly useful for
  including forms on panels.
  
  Do I just inspect element the form and grab the form id again and
  replace it with the UserLoginForm section?


You just need the ID user-register-form which means your form ID is user_register_form

I see now that you're talking about the admin form, I believe you just have to modify the formblock.module file and comment out or remove this part

 // Don't display the form to logged in users or if registration is disabled
  if (!$user-&gt;uid &amp;&amp; variable_get('user_register', 1)) {
    $block['content']['form'] = drupal_get_form('user_register_form');
    $block['subject'] = t('Create new account');
    return $block;
  }


So try:

$parameter = 'new';
$form = \Drupal::formBuilder()-&gt;getForm('user_register_form', $parameter);