Custom php in rules how to check users' geolocation lat lon field and return only users in certain area I have some custom php, sending privatemsgs to users who have some term_reference field terms that match node term_reference field terms. I need to add into this so that it only contacts users who are within a certain range of area based on their lat lon that they entered on sign up. I am sure this is a very common thing to do e.g. showing users nearby etc. If you can point me in the right direction, would be great.
How about using javascript? You could submit it with ajax and write it to the db.

Here is a good example of a javascript geolocation function to get long and altitude:

window.onload = function(){
    if(navigator.geolocation)
        navigator.geolocation.getCurrentPosition(handleGetCurrentPosition, onError);
}

function handleGetCurrentPosition(location){

    location.coords.latitude;
    location.coords.longitude;
}
function onError(){...}


More complete demo:
http://od-eon.com/labs/geolocation/

For the calculation of the distance with php:
http://www.dzone.com/snippets/distance-calculation-using-1