diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-07-22 17:41:46 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-07-22 17:41:46 +0000 |
commit | efe3cf442bc611637d525aa635f0ba1e48a0d541 (patch) | |
tree | e2717f5663f155e72f938fc92c8ae36a5b15041d | |
parent | 0dbf1662b00de6478ffdaf0ad0b3cdc445e4e42b (diff) | |
download | wordpress-mu-efe3cf442bc611637d525aa635f0ba1e48a0d541.tar.gz wordpress-mu-efe3cf442bc611637d525aa635f0ba1e48a0d541.tar.xz wordpress-mu-efe3cf442bc611637d525aa635f0ba1e48a0d541.zip |
Confirm addition of new users. fixes #630
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1395 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r-- | wp-admin/users.php | 5 | ||||
-rw-r--r-- | wp-includes/wpmu-functions.php | 16 |
2 files changed, 19 insertions, 2 deletions
diff --git a/wp-admin/users.php b/wp-admin/users.php index bc4e5da..a6fc897 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -264,8 +264,9 @@ case 'addexistinguser': if( ($username != null && is_site_admin( $username ) == false ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { $location = 'users.php?update=add_existing'; } else { - add_user_to_blog('', $user_id, $_REQUEST[ 'new_role' ]); - do_action( "added_existing_user", $user_id ); + $newuser_key = substr( md5( $user_id ), 0, 5 ); + add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user->user_email, 'role' => $_REQUEST[ 'new_role' ] ) ); + wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), "Hi,\n\nYou have been invited to join '" . get_option( 'blogname' ) . "' at\n" . site_url() . "\nPlease click the following link to confirm the invite:\n" . site_url( "/newbloguser/$newuser_key/" ) ); $location = 'users.php?update=add'; } wp_redirect("$location"); diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php index a2b64f5..3deae7a 100644 --- a/wp-includes/wpmu-functions.php +++ b/wp-includes/wpmu-functions.php @@ -1950,4 +1950,20 @@ function remove_tinymce_media_button( $buttons ) { return $buttons; } add_filter( 'mce_buttons_2', 'remove_tinymce_media_button' ); + +function add_existing_user_to_blog() { + if( false !== strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) { + $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] ); + $key = array_pop( $parts ); + if( $key == '' ) + $key = array_pop( $parts ); + $details = get_option( "new_user_" . $key ); + if( is_array( $details ) ) { + add_user_to_blog( '', $details[ 'user_id' ], $details[ 'role' ] ); + do_action( "added_existing_user", $details[ 'user_id' ] ); + wp_die( 'You have been added to this blog. Please visit the <a href="' . site_url() . '">homepage</a> or <a href="' . site_url( '/wp-admin/' ) . '">login</a> using your username and password.' ); + } + } +} +add_action( 'init', 'add_existing_user_to_blog' ); ?> |