i-recommend-this icon indicating copy to clipboard operation
i-recommend-this copied to clipboard

Add do_action("after_recommend",$post_id) hook for customization and cache refresh

Open opicron opened this issue 1 year ago • 3 comments

When using cache systems the browser is not updated after casting a vote/recommendation.

For now I hook update_post_meta and added_post_meta to check if the field _recommended is set.

It would be nice to use add_action to hook the plugins do_action hook instead.

add_action( 'added_post_meta', 'my_after_post_meta', 10, 4 );
add_action( 'updated_post_meta', 'my_after_post_meta', 10, 4 );
function my_after_post_meta( $meta_id, $post_id, $meta_key, $meta_value )
{
    if ( '_recommended' == $meta_key ) {
       //clear cache of $post_id
    }
}

opicron avatar Jul 22 '24 19:07 opicron