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 want to run some code on comment status change so using the action wp_set_comment_status but it seem to never fired when comment status gets changed. I am using wordpress 3.3.1.

Here is a simple code which doesn't work for me:

add_action('wp_set_comment_status ', 'update_business_rating_avg');

function update_business_rating_avg($comment_ID, $status){
    update_option( 'business', 'checked' );
}

There was a same bug on the wp version 2.8.2 and it was fixed later on. Not sure if i am doing something wrong or not.

http://core.trac.wordpress.org/ticket/8863

The codex says about the action:

wp_set_comment_status: Runs when the status of a comment changes. Action function arguments: comment ID, status string indicating the new status ("delete", "approve", "spam", "hold").

share|improve this question
add comment

closed as too localized by kaiser, Rarst Aug 19 '12 at 17:59

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 1 down vote accepted

Your code is showing an empty space in the hook name

add_action('wp_set_comment_status ', 'update_business_rating_avg');
                                 ^

try removing it

add_action('wp_set_comment_status', 'update_business_rating_avg');
share|improve this answer
1  
It worked. Thanks! Never imagine that might be a problem :S –  Sisir Jan 15 '12 at 14:49
add comment

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