1

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?

2

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

0

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....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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