Add 'Current User' Default Option to User Field

Currently, we can explicitly name an existing user as the default for a ‘user’ field - like this:

fields:
  author:
    label: Author
    type: user
    default: john

However, the most common use-case is to actually have the field default to the currently logged-in user - that is: whoever is logged in is who is most likely to be writing the article, not an arbitrary user.

Unfortunately, there is no way to set such a default for a user field - it’s either leave it empty, or have an explicit user. What we need is to be able to do:

fields:
  author:
    label: Author
    type: user
    default: current

You could use this custom author field (copy file to site/fields/author/author.php): https://gist.github.com/distantnative/f3918ca69173dd38fbd8

Thank you, @distantnative! - will have a look at it, for sure! :smile:

gist is missing. how to do it?

I think you can do it with the default user field now:

user:
  type: user

Thanks, very helpful.

How is that?
Tried it and it doesn’t work like this.

For me it does, just tested.