WordPress comment cookies not being set

For quite some time I thought WordPress wasn’t setting the comment cookies properly, because when I made comments the fields wouldn’t remain populated after I commented. I finally realized that if you’re logged in, you don’t have to worry about the fields at all because it pulls the name, e-mail address and URL from the user profile. This wasn’t very intuitive and the values still could have been filled in to the fields, but I realized that my theme just needed to exclude the name, e-mail and URL field if the user was logged in.

I believe there are lots of themes out there that would benefit from this change.

To update a theme, just use the conditional provided at the bottom of the get_currentuserinfo() page on the WordPress Codex.

Here’s what I added to my theme.

<?php if ('' == $user_ID) { ?>

. . . (The Name, E-mail and URL fields)

<?php } ?>




  1. That works, but PHP would probably recommend the following:

    . . . (The Name, E-mail and URL fields)

      » Comment by Chad on February 6, 2007 @ 9:17 am
  2. Haha, it’s not letting me post any php code… but what I posted was to change the following:

    if (” == $user_ID)

    to

    if (!isset($user_ID))

    Both would work, but the latter is more PHP efficient.

      » Comment by Chad on February 6, 2007 @ 9:20 am
  3. Chad: Thanks for the correction. I usually use isset() in my code, but took their example from the codex.

      » Comment by dan on February 6, 2007 @ 10:52 am


Post a comment










Number of readers
- home
comics
news links
other links

about me
blog archives
docs
entertainment
experiences
funny lists
humor
intellectual
interests
metafilter
music
opinions
photos
web designs
tools
software
webmaster help

Sign up
Enter your email address to be notified of new posts



Search blog archives

Calendar
February 2007
S M T W T F S
« Jan   Mar »
 123
45678910
11121314151617
18192021222324
25262728  







Random quote
(View all quotes)
"Good health is merely the slowest possible rate at which one can die."










(?) Choose theme:  X X X X X X