Operator is correct, WD40 is not suitable for long term lubrication as it is too volatile. It is OK to use it on the chain after riding in the rain - it will do a fair job of displacing water and grime from the links (as do many other cleaning methods) before one re-applies their chain lube of choice. Just don't squirt it into any bearings, because it will dissolve/displace the grease.
Riding in the rain doesn't cause as much difficulty some fear. If you ride in rain a lot, it is best to have hub bearings with decent seals, same goes for the headset. Most bottom bracket sealed units are very hardy. Pay attention to cleaning the wheel rims and brakepads - this will reduce wear of the rims to a good extent.
Of course, as mentioned by the others, having a whole second bike for foul weather days is a great solution - you simply can't have too many bikes

. I kept my old 10 speed bike for this purpose, but could not resist improving her over the years until she is as good as the new bike...
Cheers,
Ed