You have two ways to do this. While barand's answer is the most comp sci compliant one, it may not be able to handle load well enough.
Aggregates can get expensive, fast, in a non-linear kind of way, as your dataset grows.
It's not uncommon for a count(fieldname) to cause a sequential scan of a table, and if that table is a message table, it's may take a while.
What I'd do is run a one time transaction that both adds up all the posts and inserts that number into the user info table, then adds triggers to message table that update the user info table everytime they post. If you do it all as a single transaction, it should stay correct after that. And if it doesn't., you still have the old data to derive the answer from.
but I'm thinking from a load handling perspective, since total number of posts isn't something that has to be absolutely accurate, it's ok if it gets out of sync while you're figuring out how to make the database do the updates.