WordPress.org

Making WordPress.org

Changeset 9168


Ignore:
Timestamp:
10/09/2019 07:37:45 AM (2 years ago)
Author:
dd32
Message:

Login: Purge records from the 'pending registrations' table after 14 days.

By this time, either the account has been created, or the user_login/user_email is now available for registation again.

See #4739.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php

    r9167 r9168  
    349349    return $cache[ $cache_key ];
    350350}
     351
     352/**
     353 * Schedule a cron-task to clear pending registrations regularly.
     354 */
     355function wporg_login_cron_tasks() {
     356    if ( ! wp_next_scheduled( 'login_purge_pending_registrations' ) ) {
     357        wp_schedule_event( time(), 'daily', 'login_purge_pending_registrations' );
     358    }
     359}
     360add_action( 'admin_init', 'wporg_login_cron_tasks' );
     361
     362/**
     363 * Clears the Pending Registrations table reguarly.
     364 */
     365function wporg_login_purge_pending_registrations() {
     366    global $wpdb;
     367    $two_weeks_ago = gmdate( 'Y-m-d H:i:s', time() - 14 * DAY_IN_SECONDS );
     368
     369    $wpdb->query( $wpdb->prepare(
     370        "DELETE FROM `{$wpdb->base_prefix}user_pending_registrations`  WHERE `user_registered` <= %s",
     371        $two_weeks_ago
     372    ) );
     373}
     374add_action( 'login_purge_pending_registrations', 'wporg_login_purge_pending_registrations' );
Note: See TracChangeset for help on using the changeset viewer.