Auto login after registration

Hi I’m confused about the members area. When I used the wix version of the members area it seems to auto-login the user after registration. To meet my requirements I had to build my own, so I use this call in my backend code to register the user:

wixUsers.register(userObj.email, userObj.password)

After registration I was expecting the user to be logged in, but they are not. What is the correct approach to have the user get to a logged inn state ?

No, that will all depend on how you set up your original approval setting, which was probably set as automatically approve as default.
https://support.wix.com/en/article/editing-your-member-signup-settings-for-the-default-form

Edit the general member settings:

Who can be a member?

Choose who can be a member of your site:

Everyone: When a new member signs up, they are approved automatically. You do not need to do anything.

People I approve: When a new member signs up, you receive a notification, both by email and in your site’s dashboard, asking if you want to approve or reject them. Only those who you approve become site members.

You can make a custom signup form through Wix Forms:
https://support.wix.com/en/article/creating-a-custom-signup-form-for-your-members-area

Or you can create your own custom login and signup lightboxes instead, however if you do this option, then you will need to edit your signup settings as this:
https://support.wix.com/en/article/corvid-enabling-custom-site-registration

Have a read of the apis here for the code options
https://www.wix.com/corvid/reference/wix-users.html#register
https://www.wix.com/corvid/reference/wix-users-backend.html#register

I’m not using the wix members area, so this doesn’t apply. I have the approval set to approve everyone.

I know that you are not, however you need to setup your custom signup settings if using your own custom login/signup lightboxes:
https://support.wix.com/en/article/corvid-enabling-custom-site-registration

Then use this on your code from the api:
https://www.wix.com/corvid/reference/wix-users.html#register
https://www.wix.com/corvid/reference/wix-users-backend.html#register

Hi,

To login a user after registration you need to run the registration code client side, which means on the page itself using wix-users API

If you register the user using the register function from wix-users-backend then it means you are registering them server-side which will not do anything on the page.

Perfect! Thanks