Within a function or method, the return
statement immediately stops the execution of the earlier.
Hence the last line never gets interpreted.
Switch the order of this:
return $social_score;
update_post_meta($post_id, '_social_score', $social_score);
to this:
update_post_meta($post_id, '_social_score', $social_score);
return $social_score;
Update:
You are using three different variables for the post id, namely: $post_ID
, $post_id
and $post->ID
. You should use the function argument: $post_ID
.