I'm setting up a Drupal-powered personal blog these days, and one of my visitors asked for persistent contact information in the comment submission form,
in accordance with what I think is common practice on weblogs. It's not at all difficult to store this contact information in the guest session, with a quick patch to comment.module.
Add:
if(!$user->uid) {
$_SESSION['comment_guest_name'] = $edit['name'];
$_SESSION['comment_guest_mail'] = $edit['mail'];
$_SESSION['comment_guest_homepage'] = $edit['homepage'];
}
to the comment_save function (line 555, say), and modify the relevant parts of comment_form to take this into account—for example, the definition of the name field
in the form, in the COMMENT_ANONYMOUS_MAY_CONTACT case becomes:
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Your name'),
'#maxlength' => 60,
'#size' => 30,
'#default_value' => $edit['name'] ? $edit['name'] :
( $_SESSION['comment_guest_name'] ?
$_SESSION['comment_guest_name'] :
variable_get('anonymous', 'Anonymous')
)
);
and similarly for the other two fields, and the COMMENT_ANONYMOUS_MUST_CONTACT case.
Now, my question is: are there good reasons for not doing something like this? I guess I'm not the first user looking for such a behaviour, and it's very easy to