'.__('Hint: Use upper and lower case characters, numbers and symbols like !"?$%^&( in your password.').'
';
}
function instant_password_success($user_id=0) {
if (!$user_id) {return;}
global $bbdb;
$bbdb->query("UPDATE $bbdb->users SET user_status=0 WHERE ID=$user_id LIMIT 1"); // 0.9 has a typo bug in update_user_status function
wp_set_auth_cookie( (int) $user_id, 0 );
do_action('bb_user_login', (int) $user_id );
if (isset($_REQUEST['re'])) {$re=$_REQUEST['re'];} else {$re=bb_get_option('uri');}
bb_safe_redirect($re);
}
if ( !function_exists( 'wp_generate_password' ) ) :
function wp_generate_password( $length = 12, $special_chars = true ) {
return bb_generate_password ($length, $special_chars);
}
endif;
function bb_generate_password( $length = 12, $special_chars = true ) { // only replaces pluggable on register.php page
if (empty($_POST) || empty($_POST['password']) || empty($_POST['pass2']) || $_POST['password']!=$_POST['pass2']) {$bad=__("Your password confirmation doesn't match");}
else {$password=trim(stripslashes($_POST['password'])); $pass2=trim(stripslashes($_POST['pass2'])); if ($password!=$pass2 || strlen($password)<6) {$bad=__("Your password is too short");}}
if (empty($_POST['user_login']) || strpos($password,$_POST['user_login'])!==false || strpos($_POST['user_login'],$password)!==false) {$bad=__("Your password cannot contain your username");}
if (!empty($bad)) {instant_password_error($bad);}
return $password;
}
function instant_password_error($error) {
bb_send_headers();
bb_get_header();
echo "
".__("Error")."
".
$error.",
".__("please go back and try again").".
";
bb_get_footer();
exit;
}
if (!defined('BACKPRESS_PATH')) {
// bbPress 0.9 unfortunately allows the same email address to be used over and over, this prevents it
add_filter('bb_verify_email','instant_password_no_duplicate_email',9);
function instant_password_no_duplicate_email($email) {
if ($email) {global $bbdb; if (!$bbdb->get_row($bbdb->prepare("SELECT user_email FROM $bbdb->users WHERE user_email = %s", $email))) {return $email;}
else {instant_password_error(__("That email address is already registered"));}}
}
} else { // this freakin' nightmare brought to you by bbPress 1.0 and non-pluggable classes, thanks guys!
function bb_new_user( $user_login, $user_email, $user_url, $user_status = 1 ) {
global $wp_users_object, $bbdb;
// is_email check + dns
if ( !$user_email = bb_verify_email( $user_email ) )
return new WP_Error( 'user_email', __( 'Invalid email address' ), $user_email );
if ( !$user_login = sanitize_user( $user_login, true ) )
return new WP_Error( 'user_login', __( 'Invalid username' ), $user_login );
// user_status = 1 means the user has not yet been verified
$user_status = is_numeric($user_status) ? (int) $user_status : 1;
if ( defined( 'BB_INSTALLING' ) )
$user_status = 0;
$user_nicename = $_user_nicename = bb_user_nicename_sanitize( $user_login );
if ( strlen( $_user_nicename ) < 1 )
return new WP_Error( 'user_login', __( 'Invalid username' ), $user_login );
while ( is_numeric($user_nicename) || $existing_user = bb_get_user_by_nicename( $user_nicename ) )
$user_nicename = bb_slug_increment($_user_nicename, $existing_user->user_nicename, 50);
$user_url = $user_url ? bb_fix_link( $user_url ) : '';
$user_pass = bb_generate_password(); // workaround - this line and the next are the only two different from the core
$user = $wp_users_object->new_user( compact( 'user_login', 'user_email', 'user_url', 'user_nicename', 'user_status', 'user_pass' ) );
if ( is_wp_error($user) ) {
if ( 'user_nicename' == $user->get_error_code() )
return new WP_Error( 'user_login', $user->get_error_message() );
return $user;
}
if (BB_INSTALLING) {
bb_update_usermeta( $user['ID'], $bbdb->prefix . 'capabilities', array('keymaster' => true) );
} else {
bb_update_usermeta( $user['ID'], $bbdb->prefix . 'capabilities', array('member' => true) );
bb_send_pass( $user['ID'], $user['plain_pass'] );
}
do_action('bb_new_user', $user['ID'], $user['plain_pass']);
return $user['ID'];
}
} // end 1.0 nightmare
} // end register.php check
?>