I am having some users who have access to a limited modules. Now after a user logs in, i want to alter the permissions of that user based on the uid. I mean i should be able to add or delete some permissions of that user immediately after a user logs in. Immediately after login i wrote a custom code which executes and returns a value whether the user is active or inactive. Then based on the result i should be able to delete some permissions to access some modules of my site if inactive or add if he is active.
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