Hello again,
I'm trying to create a form for a "delete user" action. I want to delete user entries in all relevant tables and delete the profile picture. So I tried a custom code (in PHP tags):
Well, it doesn't work... Do I have to connect to the DB in the custom code? I have a DB read action in the onload event...
Moreover, I want the user to be logged out after deleting his profile. How can I achieve that?
Thanks in advance.
Christian
I'm trying to create a form for a "delete user" action. I want to delete user entries in all relevant tables and delete the profile picture. So I tried a custom code (in PHP tags):
mysql_query("DELETE FROM kwm_users WHERE id = ". $form->data['id'] ."");
mysql_query("DELETE FROM kwm_arrange2drive WHERE user_id = ". $form->data['id'] ."");
mysql_query("DELETE FROM kwm_a2d_user WHERE user_id = ". $form->data['id'] ."");
mysql_query("DELETE FROM kwm_a2d_drivealert WHERE user_id = ". $form->data['id'] ."");
mysql_query("DELETE FROM kwm_car_offers WHERE user_id = ". $form->data['id'] ."");
mysql_query("DELETE FROM kwm_gadgets WHERE user_id = ". $form->data['id'] ."");
mysql_query("DELETE FROM kwm_contact_details WHERE name = ". $form->data['name'] ."");
unlink( $_SERVER['DOCUMENT_ROOT']."/mobil3/components/com_arrange2drive/media/users/{$form->data['avatar']}" );
Well, it doesn't work... Do I have to connect to the DB in the custom code? I have a DB read action in the onload event...
Moreover, I want the user to be logged out after deleting his profile. How can I achieve that?
Thanks in advance.
Christian
Hello FenFire,
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I ask new users for information and not ask logged in users?
How to post information from a Chronoform to ZoHo
What are the 'Easy Form' and 'Form' Wizards?
How can I add a mask to format a form input?
How can I add a User to a User Group?
How do I set up user validation in my form?
How can I get information about the user?
P.S: I'm just an automated service😉
I'm not a Chrono professional, but after checking your new post, I think that the following links may help:
How can I ask new users for information and not ask logged in users?
How to post information from a Chronoform to ZoHo
What are the 'Easy Form' and 'Form' Wizards?
How can I add a mask to format a form input?
How can I add a User to a User Group?
How do I set up user validation in my form?
How can I get information about the user?
P.S: I'm just an automated service😉
Hi Christian,
Please try using the Joomla! DB code:
Be very careful deleting records from the #__users table directly - this may well leave all kinds of un-linked elsewhere in the Joomla! tables. Better check if there is a JUser method to do this and use that.
You can't log out a deleted user so I think you'd need to do that before deleting them.
Bob.
Please try using the Joomla! DB code:
$db = JFactory::getDBO();
$query = "
DELETE
FROM `#__arrange2drive`
WHERE `user_id` = '{$form->data['id']}';
";
$db->setQuery($query);
$db->execute();
. . .
Be very careful deleting records from the #__users table directly - this may well leave all kinds of un-linked elsewhere in the Joomla! tables. Better check if there is a JUser method to do this and use that.
You can't log out a deleted user so I think you'd need to do that before deleting them.
Bob.
Oh sorry, I meant the user should be logged out after "clicking the button". I looked up how to log out myself.
Thanks for your help, it works now. Here's the code (think it could be done better with array and a loop, but it's fine like this).
Thanks,
Christian
Thanks for your help, it works now. Here's the code (think it could be done better with array and a loop, but it's fine like this).
<?php
$mainframe = JFactory::getApplication();
$userid = $form->data['id'];
$name = $form->data['name'];
$avatar = $form->data['avatar'];
$mainframe->login($userid);
$db = JFactory::getDBO();
$query = "DELETE FROM `#__users` WHERE `id` = '$userid';";
$db->setQuery($query);
$db->execute();
$query = "DELETE FROM `#__a2d_user` WHERE `user_id` = '$userid';";
$db->setQuery($query);
$db->execute();
$query = "DELETE FROM `#__a2d_arrange2drive` WHERE `user_id` = '$userid';";
$db->setQuery($query);
$db->execute();
$query = "DELETE FROM `#__a2d_drivealert` WHERE `user_id` = '$userid';";
$db->setQuery($query);
$db->execute();
$query = "DELETE FROM `#__car_offers` WHERE `user_id` = '$userid';";
$db->setQuery($query);
$db->execute();
$query = "DELETE FROM `#__gadgets` WHERE `user_id` = '$userid';";
$db->setQuery($query);
$db->execute();
$query = "DELETE FROM `#__contact_details` WHERE `name` = '$name';";
$db->setQuery($query);
$db->execute();
unlink( JPATH_SITE."/components/com_arrange2drive/media/users/{$form->data['avatar']}" );
?>
Thanks,
Christian
This topic is locked and no more replies can be posted.