I want to allow the user of my website to “delete” themselves if they so desire. Although I know this is not entirely possible through wix as currently there is no user.delete code in the wix crm, can anyone provide advice on how I can achieve a similar result while still being GDPR compliant?
I was thinking of creating a button that’s linked to the dataset where the user’s information is displayed and changing the submit button to delete, that way they can delete the information stored in the collection. But then how can I prevent the user from entering my site after this is completed? I tried using the blockbyuser function but it’s not working.
Any assistance provided would be greatly appreciated.
Here’s the code I have for the blockbyuser below. This clearly doesn’t work as they’re elements missing, I just don’t know how to proceed.
import wixUsers from 'wix-users-backend';
export function button16_click(event) {}
export function myBackendFunction(email) {
wixUsers.blockByEmail(email)
.then( () => {
// user has been blocked
} );
}
They can do via Members area. For example, each user can click on the tree dots on their profile which is located on the right upper corner and choose Leave Community. Please see the photo below.
Thanks for helping. The only thing is, I don’t use the wix member’s area for my site. So it there possibly another way that users can delete their account?
import wixUsers from 'wix-users-backend';
export function myBackendFunction(email) {
wixUsers.blockByEmail(email)
.then( () => { // user has been blocked
} );
}
}
You can’t have two export functions on top of each other, there must be code between the two functions.
The export function for button 16 needs some code to tell it what it must do after the user has clicked on button 16.
Make sure that you add onReady too after the import line, so that your code runs after the page has loaded up.
Also, you can try putting the function with the onReady and maybe try doing button16 onclick event within the code too and not using the onclick event in properties.
Finally, the email string of block by email needs to be the actual email of the user you want to block so that it can return a promise for that email is blocked, so you’ll probably have to add get users email and let email = etc, etc, in the code too if you are wanting the email value automatically added instead.
Again, like this or similar:
import wixUsers from 'wix-users';
let user = wixUsers.currentUser;
user.getEmail()
.then( (email) => {
let userEmail = email; // "user@something.com"
} );
You could always just setup a help page which has a simple checkbox form with a delete my account option for the user to choose and send the form onto yourself.
Then you can manually block and delete users in Contacts yourself.
I‘ll definitely try what you suggested above. I was also thinking about sending an automated email and manually deleting the user, but I figured doing it in code was make the website more efficient as it would have a lot of users.
@givemeawhisky I’ve tried all different variations of the code but it’s still not working.
I was thinking about combing what you suggested where I would initially block the user from entering the site and then trigger an email/ send an automation to myself so that I would know how to delete the user and their content. Man I’ve tried everything I know and I just can’t get the blockbyuser function to work! And now, I’m not even sure on how to send the email to myself because automations can only be send with button submit link. Can you help, please?
This is the code I presently have:
import wixUsers from 'wix-users-backend';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
$w.onReady(function () {
let user = wixUsers.currentUser;
user.getEmail()
.then((email) => {
let userEmail = email; // "user@something.com"
})
})
export function myBackendFunction(email) {
wixUsers.blockByEmail(email)
.then(() => { // user has been blocked
$w.onReady(function () {
$w("#button16").onClick((event, $w) => {
if (wixUsers.currentUser.loggedIn) {
const userId = wixUsers.currentUser.id;
let Email = $w("#input1").value
const toInsert = {
"email": Email,
"consent": $w("#checkbox1").checked,
};
wixData.insert("DeletedAccounts", toInsert) // or "Supplier", toInsert...
wixLocation.to("/home");
}
});
})
} )
}