role to be assigned

Hey everybody,

I have a problem with creating a custom interaction which is supposed to assign a role (which is required to access a restricted page) to a user who just purchased a membership.

After the user gets redirected to my “thank you” page from a 3rd party provider he can have one of 3 status – logged in, registered (but not logged in) or a completely new user.

I want the user to enter his mail and password into input fields

The code then needs to check whether the user is currently

  1. Logged in
  2. Registered
  3. A new user

Then the user would click the “get access” button. OnClick the code needs to

  1. Add the specified role to the user
  2. Login the user AND add the specified role to the user
  3. Register the user AND add the specified role to the user

In the end, the user should be forwarded to the access only page.

I would appreciate your help as I am a total beginner with Velo. I somehow manage to get individual pieces of code to work (login, register and adding role to users). However, I cannot manage to combine them into one working code and the initial check for the user status is out of my league.

Thanks in advance

JP