Why not just include the user_id in the SELECT clause?  That way you'd get this function for free.