If you have access to RBoy Apps, then use the Door Lock User Code Management app, you can define presence based codes: