Logout after delete your profile

Hey!

I have one button connected to delete information of the database but then the user stay in that page and it’s not logging out.

Should I connect the button to the delete function with code or can I use the Wix function and also log out the user?

How could I do that?

Thanks!!!

I need help :frowning:

Hi,
You can use the logout function to log the user out. You can also redirect him to a different page using the wixLocation.to() function.

Good luck!
Tal.

Hey Tal, thanks for answering. I’m wixing the wixLocation.to fucntion, but thats not working…

export function buttonlogout_click() {
  wixUsers.logout()
        .then(() => {
 // update buttons accordingly
        $w("#login").expand();
        $w("#profileimage").collapse();
        wixLocation.to("www.example.com/welcome");        
        });
}

I also tried

export function buttonlogout_click() {
  wixUsers.logout()
  wixLocation.to(`/welcome`);        
        });
}

Hey,
The logout function is a void function, it does not returns a promise. Therefore, you don’t need to use " then ". Try the following:

export function buttonlogout_click() {   
  wixUsers.logout();
  wixLocation.to(`/welcome`); 
}

Make sure that the page URL is the same as the code (case sensitive).

Good luck,
Tal.

I think its not working because I have the button connected to the “Delete” option. So, do u know how can I codify the delete option and wixusers logout??

Thanks!!!

Hey,
I’m not sure what you were trying to delete? Were you trying to delete the user? To which delete option the button is connected?

Tal.

Well I have a update profile page were they can change their information and also delete all the information. maybe there is the problem. Should I do something else to delete their contact and also log them out?

If its not possible, is it possible to just redirect to the homepage after deleting an item? (Because I need that too when they delete a job that they have posted)

Thank you so much for the help and sorry for being so newbe hahha