Comment User_ID From EMail Address - Wordpress Plugin

I made some cool plugins to play with comments, avatars and so on. But I noticed a tiny inconvenience. Wordpress doesn't assign an user_id to comments if users are not logged in but email addresses match those of registered users. So if imaginary[at]e.mail is a registered user but is not logged in and places a comment using this very email, the comment will not be assigned to an user.

So I wrote a lame ass short plugin to do this trick. On install, it lists all your commenters' emails that have no user_id assigned to them and checks them against existing registered users. If emails match those of registered users than it will update the user_id on those comments accordingly.

The way of the Wordpress

Wordpress offers a simple way of checking if an email has an user attached. get_user_by_email(email) does the trick. So, when you list comments you can check if the $comment has an user_id > 0 to see if it was posted by a registered user. But those who don't login but keep their email address will not appear as registered unless you verify them by email using this function. This means more queries, longer code.

This plugin does it automatically just once and then you will be able to use the user_id in the $comment rather then asking Wordpress is user exists by email. Save one sql query, write less code using this short plugin.

The Plugin Source Code

This section is restricted to registered users. Please register to download this free Wordpress plugin.

Backup before you use this. Just in case ... nothing can should happen but ... backup first.

As usual, the comment form is below, more than willing to devour your thoughts.

Category: Wordpress Plugins

2 Responses

  1. $@5ubliminal57:361 — #1 says:

    UPDATE: I added a new feature that pays attention to new registrations and looks for the email of the new user in the comment database. If any comments match, they are assigned to the new User ID. This way, if a user makes a comment and then decides to register his comment will be attached to his User ID.

  2. [...] See original here: Comment User_ID From EMail Address - Wordpress Plugin | 5ubliminal … [...]