0

I've created a custom comment editor and for some reason, wp_update_comment is not working. It returns 1, which means it should have been successful but it's not actually updating anything. Listed below is my update code. It's important to note that I've double checked that the proper data is being added to $commentarr from the form POST.

$commentarr = array();
$commentarr['comment_ID'] = $comment_ID;
$commentarr['comment_content'] = $commentContent;
$update_success = wp_update_comment($commentarr);

    if ($update_success == 1) {
        $comment = get_comment($comment_ID);
        $article_link = get_permalink($comment->comment_post_ID);
        wp_redirect( $article_link );
    }

    else {
        $commentError = 'Something went wrong while updating your comment.';
        $hasError = true;
    }

**UPDATE** So after hacking away at the core, it turns out the error happens when....

do_action('edit_comment', $comment_ID);

...is called. Not sure if there's a plugin that's hooked into the edit_comment action or what but that's my guess at this point.

UPDATE #2

So the problem is DEFINITELY a BuddyPress issue. Tracked the problem to the file

bp-blogs/bp-blogs-functions.php

Going through the code now to see what the issue is but if I disable their add_action hook, I don't have any problems editing comments.

  • is comment_ID correct? – Sisir Aug 15 '14 at 4:43
  • Yes, it's correct. Otherwise, the redirect upon success wouldn't work properly since it uses the ID to get the post link. – Will S. Aug 15 '14 at 4:47
  • Impossible to say, it should work if it returns 1. I'd just start butchering core with dump statements around there... :) – Rarst Aug 15 '14 at 13:00
0

Looks like this is a core issue with BP and only affects custom commenting like I did. I'm going to mark this as resolved as they're aware of the issue now.

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.