efc9aee7 by Chris Boden

Update to address user creation on non-multisite blog. refs #784

1 parent 7cbea250
...@@ -169,7 +169,7 @@ function register($username, $email, $password, $meta = Array()) { ...@@ -169,7 +169,7 @@ function register($username, $email, $password, $meta = Array()) {
169 * @see wpmu_activate_signup 169 * @see wpmu_activate_signup
170 */ 170 */
171 function activate($key, $password_validation = null) { 171 function activate($key, $password_validation = null) {
172 global $wpdb, $current_blog; 172 global $wpdb;
173 $signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->signups} WHERE activation_key = %s", $key)); 173 $signup = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->signups} WHERE activation_key = %s", $key));
174 174
175 if (empty($signup)) { 175 if (empty($signup)) {
...@@ -200,14 +200,21 @@ function activate($key, $password_validation = null) { ...@@ -200,14 +200,21 @@ function activate($key, $password_validation = null) {
200 200
201 $wpdb->update($wpdb->signups, Array('active' => 1, 'activated' => current_time('mysql', true)), Array('activation_key' => $key)); 201 $wpdb->update($wpdb->signups, Array('active' => 1, 'activated' => current_time('mysql', true)), Array('activation_key' => $key));
202 // $user_site = get_site_option('dashboard_blog', $current_site->blog_id); 202 // $user_site = get_site_option('dashboard_blog', $current_site->blog_id);
203 add_user_to_blog($current_blog->blog_id, $id, get_site_option('default_user_role', 'subscriber')); 203
204 if (function_exists('add_user_to_blog')) {
205 global $current_blog;
206 add_user_to_blog($current_blog->blog_id, $id, get_site_option('default_user_role', 'subscriber'));
207 } else {
208 $user = new WP_User($id);
209 $user->add_role(get_site_option('default_role', 'subscriber'));
210 }
204 211
205 // If use these, fix variables, they're wrong 212 // If use these, fix variables, they're wrong
206 //add_new_user_to_blog( $id, $user_email, $meta ); 213 //add_new_user_to_blog( $id, $user_email, $meta );
207 //do_action(ACTION_ACTIVATE, $id, $password, $meta); 214 //do_action(ACTION_ACTIVATE, $id, $password, $meta);
208 215
209 // If more than the password was sent in meta, have it generate user_meta for each key=>val pair 216 // If more than the password was sent in meta, have it generate user_meta for each key=>val pair
210 foreach($meta as $key=>$val) { 217 foreach($meta as $key => $val) {
211 update_user_meta($id, $key, $val); 218 update_user_meta($id, $key, $val);
212 } 219 }
213 220
......