Making WordPress.org


Ignore:
Timestamp:
11/07/2022 03:02:46 AM (4 years ago)
Author:
dd32
Message:

Login: Use dbDelta() to create the pending user table on local environments.

File:
1 edited

Legend:

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

    r11632 r12208  
    22
    33include __DIR__  . '/class-user-registrations-list-table.php';
     4
     5add_action( 'admin_init', function() {
     6        global $wpdb;
     7        if ( 'local' !== wp_get_environment_type() ) {
     8                return;
     9        }
     10
     11        require ABSPATH . 'wp-admin/includes/upgrade.php';
     12
     13        // Check to see if the table exists.
     14        $table_sql = "CREATE TABLE `{$wpdb->base_prefix}user_pending_registrations` (
     15                `pending_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
     16                `user_login` varchar(60) NOT NULL DEFAULT '',
     17                `user_email` varchar(100) NOT NULL DEFAULT '',
     18                `user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     19                `user_activation_key` varchar(60) DEFAULT NULL,
     20                `user_profile_key` varchar(60) DEFAULT NULL,
     21                `scores` text DEFAULT NULL,
     22                `meta` text DEFAULT NULL,
     23                `cleared` tinyint(1) unsigned NOT NULL DEFAULT 1,
     24                `created` tinyint(1) unsigned NOT NULL DEFAULT 0,
     25                `created_date` datetime NOT NULL,
     26                PRIMARY KEY (`pending_id`),
     27                UNIQUE KEY `user_login` (`user_login`),
     28                UNIQUE KEY `user_email` (`user_email`)
     29        ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;";
     30
     31        dbDelta( $table_sql );
     32} );
    433
    534add_action( 'admin_menu', function() {
Note: See TracChangeset for help on using the changeset viewer.