---
title: "Users"
description: "Add Users control to your custom blocks for WordPress using the Lazy Blocks plugin."
url: "https://www.lazyblocks.com/docs/blocks-controls/users/"
lastUpdated: 2026-09-09
source: "blocks-controls/users.mdx"
---
# Users [Pro]

Users control lets you search and select WordPress users by role. Perfect for displaying team members, authors, or any user-related content.

## Control Settings

- **Filter by Role** (`users_role`) - limit the search to specific user roles. Empty by default, which searches every role
- **Output Format** (`users_output_format`) - `User ID` by default:
  - `User ID` - Returns user ID number
  - `User Object` - Hands the block a full WP_User object
- **Multiple** (`multiple`) - off by default. On, the control accepts several users and stores an array

## Usage Examples

### Single User Selection

```php title="PHP with User ID" /$attributes['control_name']/
<?php
$user_id = (int) $attributes['control_name'];
$user = get_user_by('id', $user_id);

if ($user) : ?>
    <div class="user-card">
        <?php echo get_avatar($user->ID, 64); ?>
        <h3><?php echo esc_html($user->display_name); ?></h3>
        <p><?php echo esc_html($user->description); ?></p>
    </div>
<?php endif; ?>
```

### Multiple Users

```php title="PHP with User IDs" /$attributes['control_name']/
<?php if ($attributes['control_name']) : ?>
    <div class="team-members">
        <?php foreach($attributes['control_name'] as $user_id) :
            $user = get_user_by('id', (int) $user_id);
            if ($user) : ?>
                <div class="member">
                    <?php echo get_avatar($user->ID, 96); ?>
                    <h4><?php echo esc_html($user->display_name); ?></h4>
                    <?php if ($user->user_url) : ?>
                        <a href="<?php echo esc_url($user->user_url); ?>">
                            Website
                        </a>
                    <?php endif; ?>
                </div>
            <?php endif;
        endforeach; ?>
    </div>
<?php endif; ?>
```

### Using User Object

```php title="PHP with User Object" /$attributes['control_name']/
<?php if ($attributes['control_name']) : ?>
    <div class="author-box">
        <?php
        $user = $attributes['control_name'];
        echo get_avatar($user->ID, 120);
        ?>
        <h3><?php echo esc_html($user->display_name); ?></h3>
        <?php if ($user->description) : ?>
            <div class="bio">
                <?php echo wp_kses_post($user->description); ?>
            </div>
        <?php endif; ?>
    </div>
<?php endif; ?>
```

### Handlebars Usage

Set Output Format to `User Object` when using Handlebars templates.

```hbs title="Single User" /control_name/
<div class="author-box">
  <h3>{{control_name.display_name}}</h3>
  <div class="bio">
    {{control_name.description}}
  </div>
</div>
```

```hbs title="Multiple Users" /control_name/
<div class="team-members">
  {{#each control_name}}
    <div class="member">
      <h4>{{this.display_name}}</h4>
      {{#if this.description}}
        <p>{{this.description}}</p>
      {{/if}}
    </div>
  {{/each}}
</div>
```

### Post Meta

```php title="Post Meta" /get_lzb_meta( 'control_meta_name' )/
<?php
$user_id = get_lzb_meta('control_meta_name');
if ($user_id) {
    $user = get_user_by('id', (int) $user_id);
    if ($user) {
        echo '<div class="user-info">';
        echo get_avatar($user->ID, 64);
        echo '<h3>' . esc_html($user->display_name) . '</h3>';
        echo '</div>';
    }
}
?>
```

The block stores user IDs either way. `User Object` runs the `get_users()` call for you as the block renders, so your template reaches `display_name` without making the query itself.

## Documentation Index
> Fetch the complete documentation index at: https://www.lazyblocks.com/llms.txt
> Fetch every page in a single file at: https://www.lazyblocks.com/llms-full.txt
