Is getting admission as a foreigner to a PhD program through a position within a research project of a principal investigator mostly hopeless?
Most PhDs in the bio-molecular subjects in the UK are awarded through the "job-like" route (although that is changing in some places). For most of these the position will only be open to those that count as "Home" students. Until we leave the EU in October, that includes people from the UK or the EU (after that it will just be people from the EU).

The reason for this has nothing to do with already being part of a network etc, but simply because these positions might look like jobs, but they are not. They are usually government funded PhD scholarships (where the PI has been selected to stand proxy for the government in selecting the student). For better or worst (worst in my opinion) the government has decided that its job is to educate native students (and is forced to include European students by the EU). 

However, such studentships will almost always state in the advert "Home/EU applicants only".