From 21de649fd0506ab0bf66b270125e2580dc24b1c5 Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Sun, 8 Nov 2015 03:15:07 +0000 Subject: [PATCH] MS: Allow "Network Admin Email" to be a non-user during network setup. The network admin email setting for a network is often used as a catch-all or notification email separate from the actual user ID set as the owner of the new network. If a non-user email address is set during network installation, we can defer to the current user as the actual network admin and apply the entered email as the address to which general notifications are sent and emails are sent from. In the future, we'll want to update the messaging around "Network Admin Email" to reflect its reality. See #34293. Props jjeaton. Fixes #34065. git-svn-id: https://develop.svn.wordpress.org/trunk@35575 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/schema.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 554adb8136..0dc3df913b 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -897,13 +897,18 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); - $site_user = get_user_by( 'email', $email ); if ( ! is_email( $email ) ) $errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) ); if ( $errors->get_error_code() ) return $errors; + // If a user with the provided email does not exist, default to the current user as the new network admin. + $site_user = get_user_by( 'email', $email ); + if ( false === $site_user ) { + $site_user = wp_get_current_user(); + } + // Set up site tables. $template = get_option( 'template' ); $stylesheet = get_option( 'stylesheet' ); @@ -967,7 +972,7 @@ We hope you enjoy your new site. Thanks! $sitemeta = array( 'site_name' => $site_name, - 'admin_email' => $site_user->user_email, + 'admin_email' => $email, 'admin_user_id' => $site_user->ID, 'registration' => 'none', 'upload_filetypes' => implode( ' ', $upload_filetypes ),