(2014-02-21, 06:41 AM)KLOX94 Wrote: [ -> ]So you want them to request to you that they wana delete their account even if they are offline from the board right. Then you go and send them a link to their email to remove their account ?
Almost that, let me describe it more precisely:
1) Send email with link: A mass email is sent, it will contain a link to a php page on the forum domain. This link will carry the user id
2) User clicks the link and opens the page: The user doesn't want to be a user on this forum, and then clicks on the link.
3) User fills the form with his email: The php page is opened, it informs that we are sorry he wants to unregister, but he can carry on removing the user filling a form so that he can put the email. This is to avoid people other than the user himself to remove other accounts which is not himself/herself.
4) Page processes the filled email and removes the user: The target of that form will be itself or another php page, which will take the user id, fetch the usermail and compare it with what the user filled on the form. If it matches it removes the user
(that's what I don't know how to do) and sends to a page saying the removal has been done. It it doesn't match, it send it back to the form showing an error message.
Actually I'm not very good with PHP, but I think I can do everything but:
1) How to send a link with the user ID on a mass email? I see that I can use a few variables, such as user login or user email ("{email}"). But at the moment there is no way to include the user id. Is there some workaround to enable to use the ID as a variable on the mass email? Thinking again, I could use the user login instead of the id.
2) How to remove the user based on the user login?. I will need this on step 4, so that if the email of the user fetched from DB matches the email informed by the user I would then remove the user, without removing his posts.
I noticed on the code of the admin CP that on the delete user option I have:
Quote:index.php?module=user-users&action=delete&uid=48&my_post_key=...
and looking at the delete action inside the module/user/users.php we have a routine, which I modified a bit and came up with the following:
still missing changing the query to use the username
Quote:
$query = $db->simple_select("users", "*", "uid='".intval($mybb->input['uid'])."'");
$user = $db->fetch_array($query);
// Does the user not exist?
if(!$user['uid'])
{
echo('error: no user');
return;
}
// Delete the user
$db->delete_query("userfields", "ufid='{$user['uid']}'");
$db->delete_query("privatemessages", "uid='{$user['uid']}'");
$db->delete_query("events", "uid='{$user['uid']}'");
$db->delete_query("forumsubscriptions", "uid='{$user['uid']}'");
$db->delete_query("threadsubscriptions", "uid='{$user['uid']}'");
$db->delete_query("sessions", "uid='{$user['uid']}'");
$db->delete_query("banned", "uid='{$user['uid']}'");
$db->delete_query("threadratings", "uid='{$user['uid']}'");
$db->delete_query("users", "uid='{$user['uid']}'");
$db->delete_query("joinrequests", "uid='{$user['uid']}'");
$db->delete_query("warnings", "uid='{$user['uid']}'");
$db->delete_query("reputation", "uid='{$user['uid']}' OR adduid='{$user['uid']}'");
$db->delete_query("awaitingactivation", "uid='{$user['uid']}'");
//$db->delete_query("posts", "uid = '{$user['uid']}' AND visible = '-2'");
//$db->delete_query("threads", "uid = '{$user['uid']}' AND visible = '-2'");
// Update forum stats
update_stats(array('numusers' => '-1'));
// Update forums & threads if user is the lastposter
$db->update_query("posts", array('uid' => 0), "uid='{$user['uid']}'");
$db->update_query("forums", array("lastposteruid" => 0), "lastposteruid = '{$user['uid']}'");
$db->update_query("threads", array("lastposteruid" => 0), "lastposteruid = '{$user['uid']}'");
// Did this user have an uploaded avatar?
if($user['avatartype'] == "upload")
{
// Removes the ./ at the beginning the timestamp on the end...
@unlink("../".substr($user['avatar'], 2, -20));
}
// Was this user a moderator?
if(is_moderator($user['uid']))
{
$db->delete_query("moderators", "id='{$user['uid']}' AND isgroup = '0'");
$cache->update_moderators();
}
flash_message($lang->success_user_deleted, 'success');
Is this feasible to do?