Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello !
I didn't find this request and I'm sorry if it've already been reported.
I'd like an option for the user reference to set the currently logged in user as default value.
Comments
Comment #1
marcvangendI did this using a simple custom module called user_reference_default, which contains the following code:
This code tries to set the logged in user as default for every user_reference field in the site.
For a proper contrib module, It would be needed to implement hook_form_FORM_ID_alter as well (as described in http://api.drupal.org/hook_field_widget_settings_form#comment-19724) and provide a setting to control this behavior per field instance.
Hope this helps anyone.
Comment #2
Alex Andrascu CreditAttribution: Alex Andrascu commentedComment #3
Morasta CreditAttribution: Morasta commentedThank you! I was trying the normal hook_form_alter approach without much luck. This works beautifully.