0

On the admin/content page. The field "AUTHOR" shows who created the content, but this is not very helpful for seeing who last edited it.

How would you change this to show who last edited it?

1

If you have a custom module to use, or aren't afraid to make one, then a hook_node_presave is the first method I would try.

function yourmodule_node_presave($node) {
  // php5 passes objects by reference
  // so this should not need a & or return
  global $user;
  $node->uid = $user->uid;
}

If you do not want to go with code, then try the Rules module. Rules has a trigger for node about to be saved. Set the condition that the current user is not anonymous (because rules likes you to confirm in a condition any data you want to use in the actions) and then set the author field in the action to the current user. All done in the ui, no new code needed.

  • How does this modify the view on /admin/content? – The Unknown Dev Nov 6 '18 at 17:57
  • I haven't tested, but I would expect this to change the value in the Author column of /admin/content. node->uid is a drupal core value. – DeveloperWeeks Nov 7 '18 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.