# gutenberg/22.9.0/build/scripts/block-library/form-input.php

Gutenberg, version 22.9.0. 48 lines.

- Page: https://pluginprobe.com/plugins/gutenberg/22.9.0/code/build/scripts/block-library/form-input.php
- Raw: https://pluginprobe.com/plugins/gutenberg/22.9.0/raw/build/scripts/block-library/form-input.php
- Modified: 2025-11-05T15:23:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/gutenberg/22.9.0/code/build/scripts/block-library/form-input.php#L10-L20`.

```php
<?php
/**
 * Server-side rendering of the `core/form-input` block.
 *
 * @package WordPress
 */

/**
 * Renders the `core/form-input` block on server.
 *
 * @param array  $attributes The block attributes.
 * @param string $content The saved content.
 *
 * @return string The content of the block being rendered.
 */
function gutenberg_render_block_core_form_input( $attributes, $content ) {
	$visibility_permissions = 'all';
	if ( isset( $attributes['visibilityPermissions'] ) ) {
		$visibility_permissions = $attributes['visibilityPermissions'];
	}

	$user_logged_in = is_user_logged_in();

	if ( 'logged-in' === $visibility_permissions && ! $user_logged_in ) {
		return '';
	}
	if ( 'logged-out' === $visibility_permissions && $user_logged_in ) {
		return '';
	}
	return $content;
}

/**
 * Registers the `core/form-input` block on server.
 */
function gutenberg_register_block_core_form_input() {
	if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
		return;
	}
	register_block_type_from_metadata(
		__DIR__ . '/form-input',
		array(
			'render_callback' => 'gutenberg_render_block_core_form_input',
		)
	);
}
add_action( 'init', 'gutenberg_register_block_core_form_input', 20 );

```
