Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting records from the user table #47

Open
haunted2 opened this issue Aug 31, 2021 · 2 comments
Open

Deleting records from the user table #47

haunted2 opened this issue Aug 31, 2021 · 2 comments

Comments

@haunted2
Copy link

Hello,
This plugin deletes records from the user tables if the user if it has not been confirmed for more than a certain time and is subscribed to a newsletter.

$DB->delete_records_select('user', "id " . $insql, $params);

$query = "SELECT u.id FROM {user} u INNER JOIN {newsletter_subscriptions} ns ON u.id = ns.userid WHERE u.confirmed = 0 AND :now - u.timecreated > :limit"; $ids = $DB->get_fieldset_sql($query, array('now' => time(), 'limit' => $config->activation_timeout)); if (!empty($ids)) { list($insql, $params) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED); $DB->delete_records_select('user', "id " . $insql, $params);

I believe this should be pointed out.
Not everyone might want this to happen, plus the database might get dirty because
an unconfirmed user may have custom fields in the user_info_data table, populated during account creation

@dasistwas
Copy link
Member

Thank you for pointing that out. I do think, that only users are deleted who registered via the newsletter subscription for guest users. But if there are default values for custom user profile fields that might be written to that table. Moodle deletes unconfirmed users anyway so maybe that could just be removed from the code. What do you think @haunted2 ?

@haunted2
Copy link
Author

Moodle deletes unconfirmed users (only if the scheduled task \core\task\delete_unconfirmed_users_task is active and the cron.php is running), but it uses the global function delete_user() (lib/moodlelib.php) which deletes a lot of user related stuff but not the record in the user table.

As far as I know, Moodle never physically deletes that record, but does a logical deletion, changing username, email and password, just like when an administrator deletes a user using the "trash" icon from the users list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants