File: /mnt/data/truelysell-wp-demo/catering/wp-content/themes/truelysell/assets/js/staff-remove.js
jQuery(document).ready(function ($) {
$('.delete-staff-btn').on('click', function () {
var userId = $(this).data('user-id'); // Replace with your logic to get the user ID
$.ajax({
type: 'POST',
url: ajax_object.ajax_url,
data: {
action: 'delete_controlled_user',
user_id: userId,
security: ajax_object.nonce
},
success: function (response) {
if (response.success) {
alert(response.data.message);
location.reload(); // Reload the page or update the UI as needed
} else {
alert(response.data.message);
}
},
error: function () {
alert('An error occurred while trying to delete the user.');
}
});
});
});
document.getElementById('usernameInput').addEventListener('input', function () {
this.value = this.value.replace(/\s/g, '');
});