Changeset 2076 for branches/1.1/bp-core/bp-core-signup.php
- Timestamp:
- 11/02/2009 06:56:42 PM (17 years ago)
- File:
-
- 1 edited
-
branches/1.1/bp-core/bp-core-signup.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1/bp-core/bp-core-signup.php
r2075 r2076 3 3 function bp_core_screen_signup() { 4 4 global $bp, $wpdb; 5 5 6 6 if ( $bp->current_component != BP_REGISTER_SLUG ) 7 7 return false; 8 8 9 9 /* If the user is logged in, redirect away from here */ 10 10 if ( is_user_logged_in() ) 11 11 bp_core_redirect( $bp->root_domain ); 12 12 13 13 /*** 14 14 * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function … … 21 21 if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() ) 22 22 bp_core_redirect( $bp->root_domain ); 23 23 24 24 $bp->signup->step = 'request-details'; 25 25 26 26 /* If the signup page is submitted, validate and save */ 27 27 if ( isset( $_POST['signup_submit'] ) ) { 28 28 29 29 /* Check the nonce */ 30 30 check_admin_referer( 'bp_new_signup' ); 31 31 32 32 require_once( ABSPATH . WPINC . '/registration.php' ); 33 33 34 34 /* Check the base account details for problems */ 35 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 */ 38 38 if ( !empty( $account_details['errors']->errors['user_name'] ) ) 39 39 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; 40 40 41 41 if ( !empty( $account_details['errors']->errors['user_email'] ) ) 42 42 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; 43 43 44 44 /* Check that both password fields are filled in */ 45 45 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) … … 54 54 55 55 /* Loop through the posted fields formatting any datebox values then validate the field */ 56 foreach ( (array) $profile_field_ids as $field_id ) { 56 foreach ( (array) $profile_field_ids as $field_id ) { 57 57 if ( !isset( $_POST['field_' . $field_id] ) ) { 58 58 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 59 59 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ); 60 60 } 61 61 62 62 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) ) 63 63 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); … … 67 67 if ( isset( $_POST['signup_with_blog'] ) ) { 68 68 $active_signup = get_site_option( 'registration' ); 69 69 70 70 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 71 71 $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 72 72 73 73 /* If there are errors with blog details, set them for display */ 74 74 if ( !empty( $blog_details['errors']->errors['blogname'] ) ) … … 88 88 } else { 89 89 $bp->signup->step = 'save-details'; 90 90 91 91 /* No errors! Let's register those deets. */ 92 92 $active_signup = get_site_option( 'registration' ); 93 93 94 94 if ( 'none' != $active_signup ) { 95 95 96 96 /* Let's compact any profile field info into usermeta */ 97 97 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 98 98 99 99 /* Loop through the posted fields formatting any datebox values then add to usermeta */ 100 foreach ( (array) $profile_field_ids as $field_id ) { 100 foreach ( (array) $profile_field_ids as $field_id ) { 101 101 if ( !isset( $_POST['field_' . $field_id] ) ) { 102 102 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 103 103 $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ); 104 104 } 105 105 106 106 if ( !empty( $_POST['field_' . $field_id] ) ) 107 107 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id]; 108 108 } 109 109 110 110 /* Store the profile field ID's in usermeta */ 111 111 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids']; 112 112 113 113 /* Hash and store the password */ 114 114 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] ); 115 115 116 116 /* If the user decided to create a blog, save those details to usermeta */ 117 117 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 118 118 $usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false; 119 119 } 120 120 121 121 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta ); 122 122 123 123 /* Finally, sign up the user and/or blog*/ 124 124 if ( isset( $_POST['signup_with_blog'] ) ) … … 126 126 else 127 127 wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 128 128 129 129 $bp->signup->step = 'completed-confirmation'; 130 130 } … … 132 132 do_action( 'bp_complete_signup' ); 133 133 } 134 134 135 135 } 136 136 … … 139 139 /* If user has uploaded a new avatar */ 140 140 if ( !empty( $_FILES ) ) { 141 141 142 142 /* Check the nonce */ 143 143 check_admin_referer( 'bp_avatar_upload' ); 144 144 145 145 $bp->signup->step = 'completed-confirmation'; 146 146 147 147 /* Get the activation key */ 148 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' ] ) ) ) { … … 151 151 /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */ 152 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' ) ) { 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 156 $bp->avatar_admin->step = 'crop-image'; 157 157 158 158 /* Make sure we include the jQuery jCrop file for image cropping */ 159 159 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 160 } 160 } 161 161 } 162 162 } 163 163 164 164 /* If the image cropping is done, crop the image and save a full/thumb version */ 165 165 if ( isset( $_POST['avatar-crop-submit'] ) ) { 166 166 167 167 /* Check the nonce */ 168 168 check_admin_referer( 'bp_avatar_cropstore' ); 169 169 170 170 /* Reset the avatar step so we can show the upload form again if needed */ 171 171 $bp->signup->step = 'completed-confirmation'; … … 178 178 179 179 } 180 bp_core_load_template( 'registration/register' ); 180 bp_core_load_template( 'registration/register' ); 181 181 } 182 182 add_action( 'wp', 'bp_core_screen_signup', 3 ); … … 187 187 if ( !$bp->signup->avatar_dir ) 188 188 return false; 189 189 190 190 $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' ); 191 191 $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path ); … … 193 193 194 194 $newbdir = $newdir; 195 195 196 196 if ( !file_exists( $newdir ) ) 197 197 @wp_mkdir_p( $newdir ); … … 201 201 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; 202 202 203 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 203 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 204 204 } 205 205 … … 209 209 return false; 210 210 211 if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) ) 211 if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) ) 212 212 wp_redirect( bp_root_domain() . BP_REGISTER_SLUG ); 213 213 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)