Save post id to user meta for more efficient link testing.

Also reordered some of the code to be more efficient.