Listing a Stack Overflow user as co-author for having provided substantial programming support I received a lot of help from an active Stack Overflow user in my undergrad summer research project, which was based on statistical physics. Now, I'm writing a paper on it under my professor's supervision. The professor knows about the help I received and asked me to mention it in the "acknowledgements" section (and the Stack Overflow user is OK with me mentioning them in the acknowledgements). But, I feel that the amount of programming help I received from the user deserves a little more gratitude from my side, and if possible I'd like to add the user as a co-author of the paper (obviously, after asking for consent). But, given this is my first research paper, I'm not sure what the process would entail. 

Would I face any ethical problems in case I send the paper for publication (since the SO user was obviously not "physically" present with us while I was working on the paper)? 

Also, do most journals ask for "email consent" from each and every co-author, before publication?
Physical presence is irrelevant. I'm a co-author of a four-author paper which came out of a Stack Exchange Q/A thread, none of whom have met in person.

What matters is intellectual contribution, and the question of whether contributing to code counts as sufficient intellectual contribution depends both on the specifics of the contribution and the field of research. I'm also a co-author of two or three psychology papers on the basis of having provided programming services, even though I would have expected an acknowledgement at most, because the culture of the lab (and probably the field more widely) where the lead author did her PhD was very generous with authorship.

The person best qualified to judge the contribution made by this SO user is you, followed by your professor. Your professor will also know the culture of your field. And if, as I presume, the professor is going to be a co-author, you would need them to agree to add another co-author. If you feel strongly about this, you should talk to your professor before you talk to the SO user about "upgrading" them. But since your professor has already given you guidance, and the third party is happy with that proposal, I suggest that you drop the issue unless you feel strongly about it.