/bp-forums/bbpress/register.php

  1. <?php 
  2. require('./bb-load.php'); 
  3.  
  4. bb_ssl_redirect(); 
  5.  
  6. $profile_info_keys = bb_get_profile_info_keys(); 
  7.  
  8. unset($profile_info_keys['first_name']); 
  9. unset($profile_info_keys['last_name']); 
  10. unset($profile_info_keys['display_name']); 
  11.  
  12. $user_login = ''; 
  13. $user_safe = true; 
  14.  
  15. $bb_register_error = new WP_Error; 
  16.  
  17. $_globals = array('profile_info_keys', 'user_safe', 'user_login', 'user_email', 'user_url', 'bad_input', 'bb_register_error'); 
  18. $_globals = array_merge($_globals, array_keys($profile_info_keys)); 
  19.  
  20. if ( $_POST && 'post' == strtolower($_SERVER['REQUEST_METHOD']) ) { 
  21. $_POST = stripslashes_deep( $_POST ); 
  22. $_POST['user_login'] = trim( $_POST['user_login'] ); 
  23. $user_login = sanitize_user( $_POST['user_login'], true ); 
  24. if ( $user_login !== $_POST['user_login'] ) { 
  25. $bad_input = true; 
  26. if ( $user_login ) { 
  27. $bb_register_error->add( 'user_login', sprintf( __( '%s is an invalid username. How\'s this one?' ), esc_html( $_POST['user_login'] ) ) ); 
  28. } else { 
  29. $bb_register_error->add( 'user_login', sprintf( __( '%s is an invalid username.' ), esc_html( $_POST['user_login'] ) ) ); 
  30.  
  31. foreach ( $profile_info_keys as $key => $label ) { 
  32. if ( is_string($$key) ) 
  33. $$key = esc_attr( $$key ); 
  34. elseif ( is_null($$key) ) 
  35. $$key = esc_attr( $_POST[$key] ); 
  36.  
  37. if ( !$$key && $label[0] == 1 ) { 
  38. $bad_input = true; 
  39. $$key = false; 
  40. $bb_register_error->add( $key, sprintf( __( '%s is required' ), $label[1] ) ); 
  41.  
  42. if ( !$bad_input ) { 
  43. $user_id = bb_new_user( $user_login, $_POST['user_email'], $_POST['user_url'] ); 
  44. if ( is_wp_error( $user_id ) ) { // error 
  45. foreach ( $user_id->get_error_codes() as $code ) 
  46. $bb_register_error->add( $code, $user_id->get_error_message( $code ) ); 
  47. if ( $bb_register_error->get_error_message( 'user_login' ) ) 
  48. $user_safe = false; 
  49. } elseif ( $user_id ) { // success 
  50. foreach( $profile_info_keys as $key => $label ) 
  51. if ( strpos($key, 'user_') !== 0 && $$key !== '' ) 
  52. bb_update_usermeta( $user_id, $key, $$key ); 
  53. do_action('register_user', $user_id); 
  54.  
  55. bb_load_template( 'register-success.php', $_globals ); 
  56. exit;  
  57. } // else failure 
  58.  
  59. if ( isset( $_GET['user'] ) ) 
  60. $user_login = sanitize_user( $_GET['user'], true ) ; 
  61. elseif ( isset( $_POST['user_login'] ) && !is_string($user_login) ) 
  62. $user_login = ''; 
  63.  
  64. bb_load_template( 'register.php', $_globals ); 
  65.  
  66. ?> 
.