i am working on a theme in which points are added in user meta when he does a post... it works fine but the problem is when a post is deleted by the admin then the point should be reduced and the author should get intimation . The main problem is getting the author id of the post and doing function after the post is deleted....
the code i am trying is
function deletePointFromUser($post_ID) {
global $wpdb;
$authorid = $wpdb->get_var('SELECT post_author FROM wp_posts WHERE post_id = $post_ID');
$currentPointNumber = get_usermeta($authorid, 'points');
//Delete 1 to the current Point Score
$newPointNumber = $currentPointNumber - 1;
update_usermeta( $authorid, 'points', $newPointNumber);
}
add_action('deleted_post', 'deletePointFromUser');