Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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:

https://gist.github.com/4355955

share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.