Blog · Gutenberg

User Field block for WordPress

Show a field from the logged-in user’s WordPress profile (first name, display name, email, and more). Guests see an optional fallback.

Get Blockenberg

Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.

Get Blockenberg

What it actually does

Show a field from the logged-in user’s WordPress profile (first name, display name, email, and more). Guests see an optional fallback.

Inspector panels on this block: Field, Guests & empty values, Color. Those titles come from index.js, not from a shared template.

Behavior controls: “Profile field” (Shows the logged-in user’s value on the front end); “HTML tag” options: span, p, div, h2, h3; “Field — Alignment” options: Left, Center, Right; “Fallback text for guests” (Shown when the visitor is not logged in (leave blank to show nothing if “Hide when empty” is on)).

Server render lives in render.php. Functions: bkbg_user_field_allowed_fields, bkbg_user_field_get_value, bkbg_user_field_typo_css_vars, bkbg_render_user_field_block.

Allowed values resolved in PHP: First name (`first_name`), Last name (`last_name`), Display name (`display_name`), Nickname (`nickname`), Username (`user_login`), Email (`user_email`), Website (`user_url`), Biographical info (`description`).

The current logged-in WP_User is resolved on each front-end request.

Where to find it

Gutenberg inserter → Blog → search “User Field” (block name `blockenberg/user-field` in block.json). Style it in the sidebar after insert.

How to use User Field block for WordPress

  1. Install Blockenberg. Install from WordPress.org and activate the plugin.
  2. Insert the block. Edit a page, click +, search for “User Field”, insert it. Category: Blog.
  3. Configure inspector controls that exist on this block. Open Field. Set “Profile field”, “Prefix”, “Suffix”, “HTML tag”.
  4. Publish. Save the page. Output is the saved block HTML; typography/colors follow Blockenberg shared panels.

Inspector controls from this block’s code

ControlWhat the code does
Profile fieldSelect control; the chosen value is saved on the block. Shows the logged-in user’s value on the front end. Options: First name; Last name; Display name; Nickname; Username; Email; Website; Biographical info. block.json default: first_name. Saved as `field`.
PrefixText field in the inspector. Saved as `prefix`.
SuffixText field in the inspector. Saved as `suffix`.
HTML tagSelect control; the chosen value is saved on the block. Options: span; p; div; h2; h3; h4; strong; em. block.json default: span. Saved as `htmlTag`.
Field — AlignmentSelect control; the chosen value is saved on the block. Options: Left; Center; Right. block.json default: left. Saved as `textAlign`.
Hide when value is emptyOn/off toggle in the inspector. On by default. Saved as `hideWhenEmpty`.
Hide entirely for logged-out visitorsOn/off toggle in the inspector. Off by default. Saved as `hideForGuests`.
Fallback text for guestsText field in the inspector. Shown when the visitor is not logged in (leave blank to show nothing if “Hide when empty” is on). Saved as `guestFallback`.
Text TypographyShared Blockenberg typography popover (family, size, weight, spacing). Saved as `typoText`.
Text colorColor control in the inspector. Saved as `textColor`.

When this is the right block

Notes from the implementation

render.php is a dynamic block callback — HTML is built in PHP on each request.

FAQ

How do I add the User Field block in WordPress?

Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “User Field”. It sits under Blog. After insert, open Field and set “Profile field”, “Prefix”, “Suffix”, “HTML tag”.

Can User Field show each visitor’s own data?

Yes. PHP resolves the current user on each request. Guests see the fallback or the block stays hidden — that is in render.php.

Is the User Field Gutenberg block free?

Yes. User Field ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.

Can I style User Field to match my theme?

Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Field, Guests & empty values, Color).

Related blog blocks

Get Blockenberg

Install Blockenberg from WordPress.org, then insert User Field from the Gutenberg inserter.

Get Blockenberg