Form

This block type renders a form.

Parameters

  • form – the name of a form to render;
  • redirect – true to refresh or URL to redirect the form on success;
  • values – optional field values to pre-fill;
  • attributes – the form HTML attributes.

Example

The code below renders the user registration form with an extra my-custom-class CSS class, and “<user@example.com>” default value in the Email field, refreshing the page on success.

echo ( new HivePress\Blocks\Form(
	[
		'form'       => 'user_register',
		'redirect'   => true,

		'values'     => [
			'email' => 'user@example.com',
		],

		'attributes' => [
			'class' => [ 'my-custom-class' ],
		],
	]
) )->render();