Changeset 3232 for trunk/bp-core/bp-core-signup.php
- Timestamp:
- 09/06/2010 04:24:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-signup.php
r2946 r3232 181 181 182 182 /* Make sure we include the jQuery jCrop file for image cropping */ 183 add_action( 'wp _print_scripts', 'bp_core_add_jquery_cropper' );183 add_action( 'wp', 'bp_core_add_jquery_cropper' ); 184 184 } 185 185 } … … 256 256 */ 257 257 258 /** 259 * bp_core_flush_illegal_names() 260 * 261 * Flush illegal names by getting and setting 'illegal_names' site option 262 */ 263 function bp_core_flush_illegal_names() { 264 $illegal_names = get_site_option( 'illegal_names' ); 265 update_site_option( 'illegal_names', $illegal_names ); 266 } 267 268 /** 269 * bp_core_illegal_names() 270 * 271 * Filter the illegal_names site option and make sure it includes a few 272 * specific BuddyPress and Multi-site slugs 273 * 274 * @param array|string $value Illegal names from field 275 * @param array|string $oldvalue The value as it is currently 276 * @return array Merged and unique array of illegal names 277 */ 278 function bp_core_illegal_names( $value = '', $oldvalue = '' ) { 279 280 // Make sure $value is array 281 if ( empty( $value ) ) 282 $db_illegal_names = array(); 283 if ( is_array( $value ) ) 284 $db_illegal_names = $value; 285 elseif ( is_string( $value ) ) 286 $db_illegal_names = implode( ' ', $names ); 287 288 // Add our slugs to the array and allow them to be filtered 289 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, BP_MEMBERS_SLUG, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_ACTIVITY_SLUG, BP_XPROFILE_SLUG, BP_FRIENDS_SLUG, BP_SEARCH_SLUG, BP_SETTINGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) ); 290 291 // Merge the arrays together 292 $merged_names = array_merge( (array)$filtered_illegal_names, (array)$db_illegal_names ); 293 294 // Remove duplicates 295 $illegal_names = array_unique( (array)$merged_names ); 296 297 return apply_filters( 'bp_core_illegal_names', $illegal_names ); 298 } 299 add_filter( 'pre_update_site_option_illegal_names', 'bp_core_illegal_names', 10, 2 ); 300 301 /** 302 * bp_core_validate_user_signup() 303 * 304 * Validate a user name and email address when creating a new user. 305 * 306 * @global object $wpdb DB Layer 307 * @param string $user_name Username to validate 308 * @param string $user_email Email address to validate 309 * @return array Results of user validation including errors, if any 310 */ 258 311 function bp_core_validate_user_signup( $user_name, $user_email ) { 259 global $wpdb , $bp;312 global $wpdb; 260 313 261 314 $errors = new WP_Error(); … … 268 321 preg_match( "/[a-z0-9]+/", $user_name, $maybe ); 269 322 270 $db_illegal_names = get_site_option( 'illegal_names' ); 271 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', BP_GROUPS_SLUG, $bp->members->slug, BP_FORUMS_SLUG, BP_BLOGS_SLUG, BP_REGISTER_SLUG, BP_ACTIVATION_SLUG ) ); 272 273 /* Safely merge our illegal names into existing site_option */ 274 $common_names = array_intersect( (array)$db_illegal_names, (array)$filtered_illegal_names ); 275 $diff_names = array_diff( (array)$db_illegal_names, (array)$filtered_illegal_names ); 276 $illegal_names = array_merge( (array)$diff_names, (array)$common_names ); 277 278 update_site_option( 'illegal_names', $illegal_names ); 279 280 if ( in_array( $user_name, (array)$illegal_names ) ) 281 $errors->add( 'user_name', __( 'Sorry, that username is not allowed', 'buddypress' ) ); 282 283 if ( !validate_username( $user_name ) || $user_name != $maybe[0] ) 323 // Make sure illegal names include BuddyPress slugs and values 324 bp_core_flush_illegal_names(); 325 326 if ( !validate_username( $user_name ) || in_array( $user_name, (array)$illegal_names ) || $user_name != $maybe[0] ) 284 327 $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) ); 285 328 … … 382 425 if ( !bp_core_is_multisite() ) { 383 426 $activation_key = wp_hash( $user_id ); 384 update_user meta( $user_id, 'activation_key', $activation_key );427 update_user_meta( $user_id, 'activation_key', $activation_key ); 385 428 bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key ); 386 429 } … … 445 488 446 489 /* Remove the activation key meta */ 447 delete_user meta( $user_id, 'activation_key' );490 delete_user_meta( $user_id, 'activation_key' ); 448 491 } 449 492 … … 452 495 453 496 /* Add a last active entry */ 454 update_user meta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s") );497 update_user_meta( $user_id, 'last_activity', bp_core_current_time() ); 455 498 456 499 /* Set the password on multisite installs */ … … 495 538 496 539 /* Add a last active entry */ 497 update_user meta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s") );540 update_user_meta( $user_id, 'last_activity', bp_core_current_time() ); 498 541 499 542 /* Add the user's fullname to Xprofile */ 500 543 if ( function_exists( 'xprofile_set_field_data' ) ) { 501 $firstname = get_user meta( $user_id, 'first_name');502 $lastname = ' ' . get_user meta( $user_id, 'last_name');544 $firstname = get_user_meta( $user_id, 'first_name', true ); 545 $lastname = ' ' . get_user_meta( $user_id, 'last_name', true ); 503 546 $name = $firstname . $lastname; 504 547 505 548 if ( empty( $name ) || ' ' == $name ) 506 $name = get_user meta( $user_id, 'nickname');549 $name = get_user_meta( $user_id, 'nickname', true ); 507 550 508 551 xprofile_set_field_data( 1, $user_id, $name ); … … 523 566 @wp_mkdir_p( $path ); 524 567 525 $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );568 $newurl = BP_AVATAR_URL . '/avatars/signups/' . $bp->signup->avatar_dir; 526 569 $newburl = $newurl; 527 570 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; … … 532 575 function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) { 533 576 $activate_url = bp_get_activation_page() ."?key=$key"; 534 $activate_url = clean_url( $activate_url );577 $activate_url = esc_url( $activate_url ); 535 578 $admin_email = get_site_option( "admin_email" ); 536 579
Note: See TracChangeset
for help on using the changeset viewer.