Remembering personal details in WordPress

One of the minor advantages MT has over WordPress is that the former gives a commenter the option of having the computer store his personal details (his name, email address and web URL) after he submits the comment. WordPress, on the other hand, does this automatically, so you can’t turn it off - so if you submit a comment on a public computer, such as at the cyber-cafe or the Apple Store, you leave your email address open for all to see.

Well, not on my blog anymore! I’ve hacked the theme and the comment submission PHP script so that you can choose whether to let the computer remember your details.

Here’s how.

First, you need to open the file comments.php in your theme directory. Search for “leave a comment” and you should find the HTML comment form.

You need to insert a checkbox, which I’ve done after the URL field and before the actual comment box.

<p>
<input type="checkbox" name="remember" value="remember" tabindex="4" />
<label for="remember">Remember details?</label>
</p>

I adjusted the “tabindex” on the next two fields as well, to 5 and 6 where they were 4 and 5 before.

Then, you need to open up the PHP script wp-comments-post, which you’ll find in the main blog directory.

You’ll find the following code:

setcookie('commentauthor' . COOKIEHASH, stripslashes($commentauthor),
time() + 30000000, COOKIEPATH);
setcookie('commentauthoremail' . COOKIEHASH, stripslashes($commentauthoremail),
time() + 30000000, COOKIEPATH);
setcookie('commentauthorurl' . COOKIEHASH, stripslashes($commentauthor_url),
time() + 30000000, COOKIEPATH);

You need to enclose that with the following:

if( $remember ) { 
(insert the setcookie code here)
}

And that’s it! So now you can comment here on a public computer, and nobody will be able to get your address.

Possibly Related Posts:


Share

You may also like...