Changeset 10322 for trunk/src/bp-members/bp-members-screens.php
- Timestamp:
- 11/02/2015 01:58:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-screens.php
r10276 r10322 69 69 return; 70 70 71 // Not a directory 71 // Not a directory. 72 72 bp_update_is_directory( false, 'register' ); 73 73 74 // If the user is logged in, redirect away from here 74 // If the user is logged in, redirect away from here. 75 75 if ( is_user_logged_in() ) { 76 76 … … 96 96 $bp->signup->step = 'registration-disabled'; 97 97 98 // If the signup page is submitted, validate and save 98 // If the signup page is submitted, validate and save. 99 99 } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) { 100 100 … … 106 106 do_action( 'bp_signup_pre_validate' ); 107 107 108 // Check the base account details for problems 108 // Check the base account details for problems. 109 109 $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] ); 110 110 111 // If there are errors with account details, set them for display 111 // If there are errors with account details, set them for display. 112 112 if ( !empty( $account_details['errors']->errors['user_name'] ) ) 113 113 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; … … 116 116 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; 117 117 118 // Check that both password fields are filled in 118 // Check that both password fields are filled in. 119 119 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) 120 120 $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' ); 121 121 122 // Check that the passwords match 122 // Check that the passwords match. 123 123 if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] ) 124 124 $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' ); … … 127 127 $bp->signup->email = $_POST['signup_email']; 128 128 129 // Now we've checked account details, we can check profile information 129 // Now we've checked account details, we can check profile information. 130 130 if ( bp_is_active( 'xprofile' ) ) { 131 131 132 // Make sure hidden field is passed and populated 132 // Make sure hidden field is passed and populated. 133 133 if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) { 134 134 135 // Let's compact any profile field info into an array 135 // Let's compact any profile field info into an array. 136 136 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 137 137 138 // Loop through the posted fields formatting any datebox values then validate the field 138 // Loop through the posted fields formatting any datebox values then validate the field. 139 139 foreach ( (array) $profile_field_ids as $field_id ) { 140 140 if ( !isset( $_POST['field_' . $field_id] ) ) { … … 143 143 } 144 144 145 // Create errors for required fields without values 145 // Create errors for required fields without values. 146 146 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST[ 'field_' . $field_id ] ) && ! bp_current_user_can( 'bp_moderate' ) ) 147 147 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); 148 148 } 149 149 150 // This situation doesn't naturally occur so bounce to website root 150 // This situation doesn't naturally occur so bounce to website root. 151 151 } else { 152 152 bp_core_redirect( bp_get_root_domain() ); … … 154 154 } 155 155 156 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled 156 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled. 157 157 if ( isset( $_POST['signup_with_blog'] ) ) { 158 158 $active_signup = bp_core_get_root_option( 'registration' ); … … 161 161 $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 162 162 163 // If there are errors with blog details, set them for display 163 // If there are errors with blog details, set them for display. 164 164 if ( !empty( $blog_details['errors']->errors['blogname'] ) ) 165 165 $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; … … 180 180 if ( !empty( $bp->signup->errors ) ) { 181 181 foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) { 182 // addslashes() and stripslashes() to avoid create_function() 183 // syntax errors when the $error_message contains quotes 182 /* 183 * The addslashes() and stripslashes() used to avoid create_function() 184 * syntax errors when the $error_message contains quotes. 185 */ 184 186 185 187 /** … … 200 202 if ( 'none' != $active_signup ) { 201 203 202 // Make sure the extended profiles module is enabled 204 // Make sure the extended profiles module is enabled. 203 205 if ( bp_is_active( 'xprofile' ) ) { 204 // Let's compact any profile field info into usermeta 206 // Let's compact any profile field info into usermeta. 205 207 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 206 208 207 // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile() 209 // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile(). 208 210 foreach ( (array) $profile_field_ids as $field_id ) { 209 211 if ( ! isset( $_POST['field_' . $field_id] ) ) { 210 212 211 213 if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) { 212 // Concatenate the values 214 // Concatenate the values. 213 215 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year']; 214 216 215 // Turn the concatenated value into a timestamp 217 // Turn the concatenated value into a timestamp. 216 218 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) ); 217 219 } … … 225 227 } 226 228 227 // Store the profile field ID's in usermeta 229 // Store the profile field ID's in usermeta. 228 230 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids']; 229 231 } 230 232 231 // Hash and store the password 233 // Hash and store the password. 232 234 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] ); 233 235 234 // If the user decided to create a blog, save those details to usermeta 236 // If the user decided to create a blog, save those details to usermeta. 235 237 if ( 'blog' == $active_signup || 'all' == $active_signup ) 236 238 $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false; … … 245 247 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta ); 246 248 247 // Finally, sign up the user and/or blog 249 // Finally, sign up the user and/or blog. 248 250 if ( isset( $_POST['signup_with_blog'] ) && is_multisite() ) 249 251 $wp_user_id = bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta ); … … 294 296 function bp_core_screen_activation() { 295 297 296 // Bail if not viewing the activation page 298 // Bail if not viewing the activation page. 297 299 if ( ! bp_is_current_component( 'activate' ) ) { 298 300 return false; 299 301 } 300 302 301 // If the user is already logged in, redirect away from here 303 // If the user is already logged in, redirect away from here. 302 304 if ( is_user_logged_in() ) { 303 305 … … 308 310 : bp_get_root_domain(); 309 311 310 // Trailing slash it, as we expect these URL's to be 312 // Trailing slash it, as we expect these URL's to be. 311 313 $redirect_to = trailingslashit( $redirect_to ); 312 314 … … 320 322 $redirect_to = apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to ); 321 323 322 // Redirect away from the activation page 324 // Redirect away from the activation page. 323 325 bp_core_redirect( $redirect_to ); 324 326 } 325 327 326 // grab the key (the old way)328 // Grab the key (the old way). 327 329 $key = isset( $_GET['key'] ) ? $_GET['key'] : ''; 328 330 329 // grab the key (the new way)331 // Grab the key (the new way). 330 332 if ( empty( $key ) ) { 331 333 $key = bp_current_action(); 332 334 } 333 335 334 // Get BuddyPress 336 // Get BuddyPress. 335 337 $bp = buddypress(); 336 338 337 // we've got a key; let's attempt to activate the signup339 // We've got a key; let's attempt to activate the signup. 338 340 if ( ! empty( $key ) ) { 339 341 … … 348 350 $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) ); 349 351 350 // If there were errors, add a message and redirect 352 // If there were errors, add a message and redirect. 351 353 if ( ! empty( $user->errors ) ) { 352 354 bp_core_add_message( $user->get_error_message(), 'error' ); … … 357 359 358 360 // Check if the signup avatar folder exists. If it does, move the folder to 359 // the BP user avatars directory 361 // the BP user avatars directory. 360 362 if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) { 361 363 @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user ); … … 405 407 public function is_members() { 406 408 407 // Bail if not looking at the members component or a user's page 409 // Bail if not looking at the members component or a user's page. 408 410 if ( ! bp_is_members_component() && ! bp_is_user() ) { 409 411 return; 410 412 } 411 413 412 // Members Directory 414 // Members Directory. 413 415 if ( ! bp_current_action() && ! bp_current_item() ) { 414 416 bp_update_is_directory( true, 'members' ); … … 425 427 add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); 426 428 427 // User page 429 // User page. 428 430 } elseif ( bp_is_user() ) { 429 431 … … 459 461 * 460 462 * @param array $templates The templates from bp_get_theme_compat_templates(). 461 *462 463 * @return array $templates Array of custom templates to look for. 463 464 */ 464 465 public function directory_template_hierarchy( $templates = array() ) { 465 466 466 // Set up the template hierarchy 467 // Set up the template hierarchy. 467 468 $new_templates = array(); 468 469 if ( '' !== bp_get_current_member_type() ) { … … 481 482 482 483 // Merge new templates with existing stack 483 // @see bp_get_theme_compat_templates() 484 // @see bp_get_theme_compat_templates(). 484 485 $templates = array_merge( (array) $new_templates, $templates ); 485 486 … … 527 528 * @param string $templates The templates from 528 529 * bp_get_theme_compat_templates(). 529 *530 530 * @return array $templates Array of custom templates to look for. 531 531 */ 532 532 public function single_template_hierarchy( $templates ) { 533 // Setup some variables we're going to reference in our custom templates 533 // Setup some variables we're going to reference in our custom templates. 534 534 $user_nicename = buddypress()->displayed_user->userdata->user_nicename; 535 535 … … 550 550 551 551 // Merge new templates with existing stack 552 // @see bp_get_theme_compat_templates() 552 // @see bp_get_theme_compat_templates(). 553 553 $templates = array_merge( (array) $new_templates, $templates ); 554 554 … … 612 612 public function is_registration() { 613 613 614 // Bail if not looking at the registration or activation page 614 // Bail if not looking at the registration or activation page. 615 615 if ( ! bp_is_register_page() && ! bp_is_activation_page() ) { 616 616 return; 617 617 } 618 618 619 // Not a directory 619 // Not a directory. 620 620 bp_update_is_directory( false, 'register' ); 621 621 622 // Setup actions 622 // Setup actions. 623 623 add_filter( 'bp_get_buddypress_template', array( $this, 'template_hierarchy' ) ); 624 624 add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post' ) ); … … 637 637 * 638 638 * @param string $templates The templates from bp_get_theme_compat_templates(). 639 *640 639 * @return array $templates Array of custom templates to look for. 641 640 */ … … 658 657 659 658 // Merge new templates with existing stack 660 // @see bp_get_theme_compat_templates() 659 // @see bp_get_theme_compat_templates(). 661 660 $templates = array_merge( (array) $new_templates, $templates ); 662 661 … … 670 669 */ 671 670 public function dummy_post() { 672 // Registration page 671 // Registration page. 673 672 if ( bp_is_register_page() ) { 674 673 $title = __( 'Create an Account', 'buddypress' ); … … 678 677 } 679 678 680 // Activation page 679 // Activation page. 681 680 } else { 682 681 $title = __( 'Activate Your Account', 'buddypress' );
Note: See TracChangeset
for help on using the changeset viewer.