"Authored by" field to be automatically filled On every creation of a node or edit of a node I need the "Authored by" field to be automatically populated with the username of anyone saving changes.

any ideas how I can do that?

Thanks.
Personally I think that a module like Rules (powerful and awesome as it is) is overkill for something relatively simple as this.

Looking at node_form(), I see that the author is set by populating the author field with the username. I would create a custom module which implements hook_form_BASE_FORM_ID_alter, and set the default value of the author name field to the name of the current user. That would look something like this (disclaimer: untested code!).

&lt;?php

function MODULENAME_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // Always set the username to the current user. An empty string means anonymous.
  global $user;
  $form['author']['name']['#default_value'] = !empty($user-&gt;name) ? $user-&gt;name : '';
}


An advantage of this solution is that the field is populated in advance with a default value, allowing user with sufficient permissions (eg. administrators) to override the author as they always can. It would be harder to do that in a rules-based approach which only kicks in after the form has been submitted.



update:

The topic starter mentions in another answer that he ended up with the following code:

function module_name_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // Always set the username to the current user. An empty string means anonymous.
  global $user;
  if ($form_id == 'content_type_node_form') {
    $form['author']['name']['#default_value'] = $user-&gt;name;
  }
}


Some feedback on this code:


Of course, the if-statement makes sense if you only need this behavior in certain cases. You could even place the global $user; inside the if.
I would recommend that you keep the !empty($user-&gt;name) ? $user-&gt;name : '' part, instead of simply using $user-&gt;name. It may be an edge case, but as you can see in drupal_anonymous_user, the global $user object does not necessarily contain a 'name' property. If, at some point in the future, this form would become available for anonymous users, they will end up with php notices on their screen.