Ticket #35428: ms-functions.php.2.patch
File ms-functions.php.2.patch, 2.5 KB (added by , 8 years ago) |
---|
-
wp-includes/ms-functions.php
952 952 function wpmu_activate_signup($key) { 953 953 global $wpdb; 954 954 955 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );955 $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key ) ); 956 956 957 if ( empty( $signup ) ) 957 if ( empty( $signup ) ) { 958 958 return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) ); 959 } 959 960 960 961 if ( $signup->active ) { 961 if ( empty( $signup->domain ) ) 962 if ( empty( $signup->domain ) ) { 962 963 return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup ); 963 else964 } else { 964 965 return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup ); 966 } 965 967 } 966 968 967 $meta = maybe_unserialize($signup->meta);969 $meta = maybe_unserialize( $signup->meta ); 968 970 $password = wp_generate_password( 12, false ); 969 971 970 $user_id = username_exists( $signup->user_login);972 $user_id = username_exists( $signup->user_login ); 971 973 974 if ( ! $user_id ) { 975 $user_id = wpmu_create_user( $signup->user_login, $password, $signup->user_email ); 976 } else { 977 $wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) ); 978 } 979 /** 980 * allow the suppression of errors if user already exists. 981 * 982 * @since 4.5 983 * 984 * @param WP_Error 985 */ 986 $user_already_exists = apply_filters('_wpmu_activate_existing_error_', true, $signup ); 987 } 972 988 if ( ! $user_id ) 973 $user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);974 else975 $user_already_exists = true;976 977 if ( ! $user_id )978 989 return new WP_Error('create_user', __('Could not create user'), $signup); 979 990 980 991 $now = current_time('mysql', true); … … 981 992 982 993 if ( empty($signup->domain) ) { 983 994 $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) ); 995 996 if ( isset( $user_already_exists ) ){ 997 return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup, get_defined_vars() ); 998 } 984 999 985 if ( isset( $user_already_exists ) )986 return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);987 988 1000 /** 989 1001 * Fires immediately after a new user is activated. 990 1002 *