Ticket #31127: 31127.diff
File 31127.diff, 4.0 KB (added by , 8 years ago) |
---|
-
src/wp-includes/ms-functions.php
480 480 // If registered more than two days ago, cancel registration and let this signup go through. 481 481 if ( $diff > 2 * DAY_IN_SECONDS ) 482 482 $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) ); 483 else 484 $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); 483 else { 484 // If the username has already been used for a signup on this site, disallow it. 485 $meta = maybe_unserialize($signup->meta); 486 if ( $meta['add_to_blog'] === get_current_blog_id() ) { 487 $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.')); 488 } 489 } 485 490 } 486 491 487 492 $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) ); … … 490 495 // If registered more than two days ago, cancel registration and let this signup go through. 491 496 if ( $diff > 2 * DAY_IN_SECONDS ) 492 497 $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) ); 493 else 494 $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); 498 else { 499 // If the email address has already been used for a signup on this site, disallow it. 500 $meta = maybe_unserialize($signup->meta); 501 if ( $meta['add_to_blog'] === get_current_blog_id() ) { 502 $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.')); 503 } 504 } 505 495 506 } 496 507 497 508 $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors); … … 719 730 $key = substr( md5( time() . rand() . $user_email ), 0, 16 ); 720 731 $meta = serialize($meta); 721 732 722 $wpdb->insert( $wpdb->signups, array( 723 'domain' => '', 724 'path' => '', 725 'title' => '', 726 'user_login' => $user, 727 'user_email' => $user_email, 728 'registered' => current_time('mysql', true), 729 'activation_key' => $key, 730 'meta' => $meta 731 ) ); 733 $existing_signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) ); 732 734 735 if ( $existing_signup === null ) { 736 $wpdb->insert( $wpdb->signups, array( 737 'domain' => '', 738 'path' => '', 739 'title' => '', 740 'user_login' => $user, 741 'user_email' => $user_email, 742 'registered' => current_time('mysql', true), 743 'activation_key' => $key, 744 'meta' => $meta 745 ) ); 746 } else { 747 748 // If there's already a signup for this email address, 749 // note if the user should be signed up for another site. 750 $diff = current_time( 'timestamp', true ) - mysql2date('U', $existing_signup->registered); 751 // If registered less than two days ago, add another signup for the user. 752 if ( $diff <= 2 * DAY_IN_SECONDS ) { 753 $new_signup_meta = maybe_unserialize( $existing_signup->meta ); 754 if ( $new_signup_meta['add_to_blog'] != get_current_blog_id() ) { 755 if ( isset ( $new_signup_meta['other_blogs'] ) ) { 756 $new_signup_meta['other_blogs'] = array(); 757 } 758 $new_signup_meta['other_blogs'][] = maybe_unserialize( $meta ); 759 $wpdb->update( 760 $wpdb->signups, 761 array( 'meta' => maybe_serialize( $new_signup_meta ) ), 762 array( 'signup_id' => $existing_signup->signup_id ) 763 ); 764 } 765 } 766 } 767 733 768 /** 734 769 * Fires after a user's signup information has been written to the database. 735 770 * … … 2018 2053 add_user_to_blog( $blog_id, $user_id, $role ); 2019 2054 update_user_meta( $user_id, 'primary_blog', $blog_id ); 2020 2055 } 2056 if ( ! empty( $meta['other_blogs'] ) ) { 2057 foreach( $meta['other_blogs'] as $add_to_blog_info ) { 2058 $blog_id = $add_to_blog_info[ 'add_to_blog' ]; 2059 $role = $add_to_blog_info[ 'new_role' ]; 2060 add_user_to_blog( $blog_id, $user_id, $role ); 2061 } 2062 } 2021 2063 } 2022 2064 2023 2065 /**