Why do you want to know if a user is a teacher? What are you going to do, or not do, based on that knowledge?
has_capability does not know anything about groups, I suspect the group restriction is coming from elsewhere in the code. Where is $user coming from.
Roles and permissions
Question about roles system.
This discussion has been locked so you can no longer reply to it.