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.
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
- Insert User Field on a page meant for members. Account, dashboard, or membership content.
- Pick the profile field. First name, last name, display name, nickname, username, email, website, or biographical info.
- Set guest behavior. guestFallback for logged-out visitors, or hideForGuests to output nothing.
- Preview logged in and logged out. PHP render depends on is_user_logged_in() and wp_get_current_user().
Controls and behavior
| Piece | What the plugin does |
|---|---|
| field | Whitelisted profile key; invalid values become first_name. |
| prefix / suffix | Strings wrapped around the resolved value. |
| guestFallback / hideForGuests / hideWhenEmpty | Logged-out and empty-value behavior. |
| htmlTag / typoText | Wrapper tag plus TypographyControl CSS variables. |
When this is the right tool
- A greeting that uses the member’s display name.
- Account pages built in Gutenberg without a page builder.
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
Block Manager: enable and disable Gutenberg blocks
A wp-admin dashboard that stores disabled block names in blockenberg_disabled_blocks and skips those folders during register_block_type and asset registration.
Inspector tabs: General vs Advanced on every Blockenberg block
A BlockEdit higher-order component (inspector-tabs.js) injects General / Advanced tabs on all blockenberg/* blocks and registers shared layout attributes.
Layout system: shared spacing and background CSS for every block
Server-registered bkbg* attributes and a render_block filter that prints desktop inline CSS plus tablet/mobile media queries. layout.css is shared by section/row/column.
Typography control: a shared font popover and Google Fonts loader
window.bkbgTypographyControl is a reusable popover. On the front, blockenberg.php scans *Typo / typo* attributes for family and enqueues Google Fonts CSS2 URLs (skipping system fonts).
Icon picker: one control for Dashicons, SVG, and images
window.bkbgIconPicker exposes IconPickerControl, editor/save builders, and a frontend DOM builder. Icon types include Dashicons, bundled SVG paths, and media uploads.
Get Blockenberg
Install the plugin from WordPress.org, then use this feature in the native block editor.