Select user/author from dropdown

I run a website that has multiple editors. Currently I add authors to articles with a text field.
Now I’d like a select/dropdown that lists all the users in panel to add as author.
There is no “users” option to fetch in the Kirby Select documentation that I can use.

I know I could do the trick by fetching a set of subpages but I’d like to use Kirby’s built in user management because I’d regularly have to add both a subpage and a user to give them panel acces.

Once that’s figured out I’d also like to create author pages for them. I found a forum post showing how to do it with routers from a few months ago… Would this still be the optimal way of doing this?

You will be happy to hear that instead of a text field you can simply use:

author:
  label: Author
  type: user
1 Like

Oh dear, how did I not know this exists :sweat_smile:
Thank you!

1 Like

Could this be extended with your multi-select field? @distantnative, so I could select multiple people that are working on one article, and then somehow access their information inside a loop?

The multiselect field uses the same options as the native checkboxes and select fields. Without making any changes to the field, you could use the query API to fetch a list of users as options.

An alternative would be to fork the field and set the options to users. A simple way to achieve this would be to change the constructor in /field/field-multiselect/field/multiselect.php like this:

  public function __construct() {
    $this->icon = 'chevron-down';

    foreach(kirby()->site()->users() as $user) {
      $this->options[$user->username()] = $user->username();
    }
  }