How to alter the default user permisions based on a returned value after login?
user_role_grant_permissions can help you. Or you are using modules which grant permissions based on users not on roles? If yes, look into code of module which control permissions per user to find proper function