Feature · Gutenberg · Blockenberg

User Field: a dynamic Gutenberg block with PHP render

Almost every Blockenberg block is static block.json + JavaScript. User Field is different: it has a PHP render callback so the published page shows the current user’s data.

Get Blockenberg

Blockenberg is a Gutenberg block library. These features are plugin-wide editor tools, not Elementor extensions.

Get Blockenberg

What it actually does

bkbg_user_field_allowed_fields() whitelists: first_name, last_name, display_name, nickname, user_login, user_email, user_url, description. Unknown field keys fall back to first_name.

bkbg_render_user_field_block() reads attributes field, prefix, suffix, guestFallback, hideWhenEmpty, hideForGuests, htmlTag, textAlign, plus typography object typoText. Logged-in users get bkbg_user_field_get_value( wp_get_current_user(), field ). Guests see guestFallback unless hideForGuests is true (then the block returns empty).

Allowed HTML tags: span, p, div, h2, h3, h4, strong, em. Other blocks do not get a per-block PHP render file from this require.

Where it lives in WordPress

Inserter → search User Field (blockenberg/user-field). Implementation: blocks/user-field/render.php required from the main plugin file. Dedicated block doc: User Field block guide.

How to use it

  1. Insert User Field on a page meant for members. Account, dashboard, or membership content.
  2. Pick the profile field. First name, last name, display name, nickname, username, email, website, or biographical info.
  3. Set guest behavior. guestFallback for logged-out visitors, or hideForGuests to output nothing.
  4. Preview logged in and logged out. PHP render depends on is_user_logged_in() and wp_get_current_user().

Controls and behavior

PieceWhat the plugin does
fieldWhitelisted profile key; invalid values become first_name.
prefix / suffixStrings wrapped around the resolved value.
guestFallback / hideForGuests / hideWhenEmptyLogged-out and empty-value behavior.
htmlTag / typoTextWrapper tag plus TypographyControl CSS variables.

When this is the right tool

Notes from the code

This feature page exists so people searching “Blockenberg dynamic user” do not assume every block is PHP-dynamic. Product: blockenberg.com.

FAQ

Why is my name missing when logged out?

Set guestFallback for guests, or hideForGuests if the block should output nothing. Logged-out users have no profile fields.

Is this a form?

No. It displays profile fields; it does not edit wp_users.

Other plugin features

Get Blockenberg

Install the plugin from WordPress.org, then use this feature in the native block editor.

Get Blockenberg