I don't want this to sound overly alarmist, but there are certain precautions that the inexperienced gay traveler should take when meeting local guys in developing countries.
Costa Ricans are very friendly people and are pretty open about gay life. However, given that it is a poorer country, there is a segment of the population that preys upon foreigners. Keep in mind that the average unskilled working stiff makes about $20-$25 day.
I have lived in Costa Rica for 11 years and over that time I have learned a few things (thankfully not the hard way).
Street art in San Jose. A lot of streets in the capital empty out after dark so keep to areas with people or take a taxi. Photo by Josh.
Here are some basic tips to keep you safe
Do not walk around downtown San Jose at night except in heavy tourist areas. Taxis (and UBER) are not expensive and are usually available outside all the gay bars. If you are leaving from a bar or sauna and do not see a taxi, have the counter person or door-person call one for you.
If walking around during the day, refrain from wearing jewellery such as gold chains, watches etc. Also keep displays of using such items as cell phones and iPods to an minimum. You are just sending out messages that you have "goodies".
When going out, keep the amount of cash that you have with you to the just amount you need for that night. You also can leave all ID including passport in your hotel safe. You are required to have a photo-copy of your passport with the entry stamp as well. This is legal ID all over Costa Rica except when you do face-to-face bank transactions and the original is required. Try and have photo copies done before you leave, but if you do not, most decent hotels will do it for you.
Keep park cruising to day light hours. If cruising around downtown parks, there are very cheap hotels close by that you can go to for sex. Latin culture is designed this way as very few people live alone and given that Latinos are very horny, casual encounters and sex outside of relationships is very common.
If you bring someone back to your hotel room, make sure that he is not expecting money. If he is, negotiate the price and what that includes ahead of time.
Most gay hotels and hotels that are used to guests bringing back local friends make person register at desk with ID. This is a good thing as it is for your protection and other guests. If your new found friend does not have ID, that should be your first sign that he might not be trustworthy. I would stick to taking him to a sex hotel or sauna.
If you do not know the person or do not have reliable references about the persons character, it is not advisable for you to have him stay the night.
Make sure all your valuables in your hotel room are locked up. It is a very good idea that until you know someone not to display signs of wealth such as cash, credit cards, cell phones, computers, etc.
If having sex in venues like sex clubs or parks, be very mindful about things in your pockets such as car keys, cash or wallet.
If you are a victim of crime or threats, my advice would be to call the police. That will usually end things right there. Almost anyone involved in illegal activity does not want to deal with the police. They are counting on that you are too afraid to call.
Unlike other Latin countries I have visited, the police in Costa Rica overall are quite friendly and will try and help. The whole country on a whole is not really homophobic and even though many do not approve of homosexuality, they are not hostile about it.