# Programatically create user \*with content\*

**URL:** <https://forum.getkirby.com/t/programatically-create-user-with-content/33768>\
**Category:** Questions\
**Tags:** v5\
**Created:** [March 13, 2025, 8:45am UTC](https://forum.getkirby.com/t/programatically-create-user-with-content/33768 "2025-03-13T08:45:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daizumi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/daizumi/32/11799_2.png) [@daizumi](https://forum.getkirby.com/u/daizumi)\
**Post date:** [March 13, 2025, 8:45am UTC](https://forum.getkirby.com/t/programatically-create-user-with-content/33768/1 "2025-03-13T08:45:27Z")

</div>

Hi there,

In my user registration page, I need to create a user and on creation assign it some values to some fields.

In my registration controller, this works:

```auto
$user = $kirby->users()->create([
  'email' => $email,
  'password' => $password,
  'role' => 'exhibitor',
  'language' => 'en',
  'name' => $name
]);
$user->update([
  'exhibitor' => $exhibitor,
  'isVerified' => false,
  'token' => $token
]);

```

But this shorter, more elegant version, inspired by the [docs](https://getkirby.com/docs/reference/objects/cms/user/create), doesn’t:

```auto
$kirby->users()->create([
  'email' => $email,
  'password' => $password,
  'role' => 'exhibitor',
  'language' => 'en',
  'name' => $name,
  'content' => [
    'exhibitor' => $exhibitor,
    'isVerified' => false,
    'token' => $token
  ]
]);

```

Why?

No big deal if that’s the only way it can be done, but would like to at least understand the reason for this.

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [March 13, 2025, 9:43am UTC](https://forum.getkirby.com/t/programatically-create-user-with-content/33768/2 "2025-03-13T09:43:53Z")

</div>

Do you have multi-language setup?

---

<div class="post-metadata">

**Author:** ![daizumi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/daizumi/32/11799_2.png) [@daizumi](https://forum.getkirby.com/u/daizumi)\
**Post date:** [March 13, 2025, 9:53am UTC](https://forum.getkirby.com/t/programatically-create-user-with-content/33768/3 "2025-03-13T09:53:37Z")

</div>

I do.

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [March 13, 2025, 10:07am UTC](https://forum.getkirby.com/t/programatically-create-user-with-content/33768/4 "2025-03-13T10:07:41Z")

</div>

So you need to use `translations` index instead `content`:

```php
$kirby->users()->create([
	'email' => $email,
	'password' => $password,
	'role' => 'exhibitor',
	'language' => 'en',
	'name' => $name,
	'translations' => [
		[
			'code' => 'en',
			'content' => [
				'exhibitor' => $exhibitor,
				'isVerified' => false,
				'token' => $token
			]
		]
	]
]);

```

---

<div class="post-metadata">

**Author:** ![daizumi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/daizumi/32/11799_2.png) [@daizumi](https://forum.getkirby.com/u/daizumi)\
**Post date:** [March 13, 2025, 11:15am UTC](https://forum.getkirby.com/t/programatically-create-user-with-content/33768/5 "2025-03-13T11:15:00Z")

</div>

Yes, that did it! Thanks, @ahmetbora!
