Add a profile field
Add a field, say "Desired User Role", to the user profile.
Create a 1st Rule
- Rules Event: After user login.
- Rules Actions:
- Remove role A, B, C and D for user.
- Perform a redirect to
user/uid/edit (to show the user's profile in edit mode).
- Set a Drupal message like "Select your desired User Role".
Create a 2nd Rule
- Rules Event: After updating a user profile.
- Rules Conditions (AND):
- User ID of the user for which the profile is updated is current site user (to not block user profile edits by other authorized users).
- Field Desired User Role (unchanged) is not eaqual to Desired User Role.
- Rules Action (using the Conditional Rules module to allow conditions to be contained within Rules Actions):
- If selected Desired User Role=A then grant access to role A.
- If selected Desired User Role=B then grant access to role B.
- If selected Desired User Role=C then grant access to role C.
- If selected Desired User Role=D then grant access to role D.
This rule also facilitates swapping from one role to another (without forcing an indermediate logout/login). If that's NOT what you want, then this rule needs further refinement. I.e. add an extra Rules Condition to also check that no Desired User Role (unchanged) was selected before trying to update it.
Note: for this to work, a user can have multiple "other roles", but they should not overlap with A, B, C or D.