Changeset 2209 for trunk/bp-core/bp-core-signup.php
- Timestamp:
- 12/27/2009 10:41:10 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-signup.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-signup.php
r2077 r2209 19 19 20 20 /* If signups are disabled, just re-direct */ 21 if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() )21 if ( !bp_get_signup_allowed() || 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() ) 22 22 bp_core_redirect( $bp->root_domain ); 23 23 … … 33 33 34 34 /* Check the base account details for problems */ 35 $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] );35 $account_details = wpmu_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] ); 36 36 37 37 /* If there are errors with account details, set them for display */ … … 49 49 if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] ) 50 50 $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' ); 51 52 $bp->signup->username = $_POST['signup_username']; 53 $bp->signup->email = $_POST['signup_email']; 51 54 52 55 /* Now we've checked account details, we can check profile information */ … … 122 125 123 126 /* Finally, sign up the user and/or blog*/ 124 if ( isset( $_POST['signup_with_blog'] ) )127 if ( isset( $_POST['signup_with_blog'] ) && bp_core_is_multiblog_install() ) 125 128 wpmu_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 126 else 127 wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 129 else { 130 bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta ); 131 } 128 132 129 133 $bp->signup->step = 'completed-confirmation'; … … 145 149 $bp->signup->step = 'completed-confirmation'; 146 150 147 /* Get the activation key */ 148 if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) { 149 bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) ); 150 } else { 151 /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */ 152 $bp->signup->avatar_dir = wp_hash( $bp->signup->key ); 153 154 /* Pass the file to the avatar upload handler */ 155 if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) { 156 $bp->avatar_admin->step = 'crop-image'; 157 158 /* Make sure we include the jQuery jCrop file for image cropping */ 159 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 160 } 151 if ( bp_core_is_multiblog_install() ) { 152 /* Get the activation key */ 153 if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) { 154 bp_core_add_message( __( 'There was a problem uploading your avatar, please try uploading it again', 'buddypress' ) ); 155 } else { 156 /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */ 157 $bp->signup->avatar_dir = wp_hash( $bp->signup->key ); 158 } 159 } else 160 $bp->signup->avatar_dir = wp_hash( $bp->signup->username ); 161 162 /* Pass the file to the avatar upload handler */ 163 if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) { 164 $bp->avatar_admin->step = 'crop-image'; 165 166 /* Make sure we include the jQuery jCrop file for image cropping */ 167 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 161 168 } 162 169 } … … 182 189 add_action( 'wp', 'bp_core_screen_signup', 3 ); 183 190 191 function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) { 192 global $bp; 193 194 if ( bp_core_is_multiblog_install() ) 195 return wpmu_signup_user( $user_login, $user_email, $usermeta ); 196 197 $errors = new WP_Error(); 198 199 $user_id = wp_create_user( $user_login, $user_password, $user_email ); 200 if ( !$user_id ) { 201 $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email'))); 202 return $errors; 203 } 204 205 /* Set any profile data */ 206 if ( function_exists( 'xprofile_set_field_data' ) ) { 207 if ( !empty( $usermeta['profile_field_ids'] ) ) { 208 $profile_field_ids = explode( ',', $usermeta['profile_field_ids'] ); 209 210 foreach( $profile_field_ids as $field_id ) { 211 $current_field = $usermeta["field_{$field_id}"]; 212 213 if ( !empty( $current_field ) ) 214 xprofile_set_field_data( $field_id, $user_id, $current_field ); 215 } 216 } 217 } 218 219 wp_new_user_notification( $user_id, $user_pass ); 220 221 $bp->signup->username = $user_login; 222 223 return $user_id; 224 } 225 184 226 function bp_core_signup_avatar_upload_dir() { 185 227 global $bp; … … 188 230 return false; 189 231 190 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 191 $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path ); 192 $newdir .= '/avatars/signups/' . $bp->signup->avatar_dir; 193 194 $newbdir = $newdir; 195 196 if ( !file_exists( $newdir ) ) 197 @wp_mkdir_p( $newdir ); 198 199 $newurl = WP_CONTENT_URL . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $bp->signup->avatar_dir; 232 $path = BP_AVATAR_UPLOAD_PATH . '/avatars/signups/' . $bp->signup->avatar_dir; 233 $newbdir = $path; 234 235 if ( !file_exists( $path ) ) 236 @wp_mkdir_p( $path ); 237 238 $newurl = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $path ); 200 239 $newburl = $newurl; 201 240 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; 202 241 203 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $ newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );242 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 204 243 } 205 244
Note: See TracChangeset
for help on using the changeset viewer.