root/trunk/register.php

Revision 1660, 2.2 kB (checked in by mdawaffe, 1 day ago)

initialize $user_login to be empty. Fixes #933

  • Property svn:eol-style set to native
Line 
1 <?php
2 require('./bb-load.php');
3
4 bb_ssl_redirect();
5
6 require_once( BB_PATH . BB_INC . 'registration-functions.php');
7
8 $profile_info_keys = get_profile_info_keys();
9
10 unset($profile_info_keys['first_name']);
11 unset($profile_info_keys['last_name']);
12 unset($profile_info_keys['display_name']);
13
14 $user_login = '';
15 $user_safe = true;
16
17 $bb_register_error = new WP_Error;
18
19 $_globals = array('profile_info_keys', 'user_safe', 'user_login', 'user_email', 'user_url', 'bad_input', 'bb_register_error');
20 $_globals = array_merge($_globals, array_keys($profile_info_keys));
21
22 if ( $_POST && 'post' == strtolower($_SERVER['REQUEST_METHOD']) ) {
23     $_POST = stripslashes_deep( $_POST );
24     $_POST['user_login'] = trim( $_POST['user_login'] );
25     $user_login = sanitize_user( $_POST['user_login'], true );
26     if ( $user_login !== $_POST['user_login'] ) {
27         $bad_input = true;
28         $bb_register_error->add( 'user_login', sprintf( __( "%s is an invalid username.  How's this one?" ), wp_specialchars( $_POST['user_login'] ) ) );
29     }
30
31     foreach ( $profile_info_keys as $key => $label ) {
32         if ( is_string($$key) )
33             $$key = attribute_escape( $$key );
34         elseif ( is_null($$key) )
35             $$key = attribute_escape( $_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     }
43
44     if ( !$bad_input ) {
45         $user_id = bb_new_user( $user_login, $_POST['user_email'], $_POST['user_url'] );
46         if ( is_wp_error( $user_id ) ) { // error
47             foreach ( $user_id->get_error_codes() as $code )
48                 $bb_register_error->add( $code, $user_id->get_error_message( $code ) );
49             if ( $bb_register_error->get_error_message( 'user_login' ) )
50                 $user_safe = false;
51         } elseif ( $user_id ) { // success
52             foreach( $profile_info_keys as $key => $label )
53                 if ( strpos($key, 'user_') !== 0 && $$key !== '' )
54                     bb_update_usermeta( $user_id, $key, $$key );
55             do_action('register_user', $user_id);
56
57             bb_load_template( 'register-success.php', $_globals );
58             exit;   
59         } // else failure
60     }
61 }
62
63 if ( isset( $_GET['user'] ) )
64     $user_login = sanitize_user( $_GET['user'], true ) ;
65 elseif ( isset( $_POST['user_login'] ) && !is_string($user_login) )
66     $user_login = '';
67
68 bb_load_template( 'register.php', $_globals );
69
70 ?>
71
Note: See TracBrowser for help on using the browser.