WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site that used Facebook comments for a period of time and then removed them for native WP comments. I was able to write a function that grabbed all the comments and re-inserted them into the WP database (as FB comments do not store in WP). However, Facebook's OpenGraph API does not provide email addresses (which I understand).

So what I want to accomplish is the following:

  1. Query the comment table for a specific name using the comment_author
  2. Pull all comments by that name
  3. If there is an email address present in one comment array, copy it over to the one that is missing

I have accomplished #1 and #2, but I'm at a loss for #3. Any ideas?

share|improve this question

After some more thought, I got it figured out. It involves multiple functions to go through each step of the process, but here it is:


share|improve this answer

I don't know the schema, but if you're doing it for one specific author at a time, something along the lines of:

$foo = $db->Execute("SELECT DISTINCT(email) FROM comments WHERE comment_author = ? AND email <> ''",$authorname);
if ($foo->count > 0) {
  $db->Execute("UPDATE comments SET email = ? WHERE comment_author = ? AND email <> ''",$foo[0],$authorname);

Apologies for assuming some random, generic db object/interface....

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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