Changeset 967
- Timestamp:
- 04/10/08 14:28:56 (8 months ago)
- Files:
-
- admin-add-user/trunk/admin-add-user.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
admin-add-user/trunk/admin-add-user.php
r700 r967 2 2 /** 3 3 * Plugin Name: Admin add user 4 * Plugin Description: Allows Keymasters to add user through the administration panel.4 * Plugin Description: Allows keymasters to add user through the administration panel. 5 5 * Author: Thomas Klaiber 6 6 * Author URI: http://thomasklaiber.com/ 7 7 * Plugin URI: http://thomasklaiber.com/bbpress/admin-add-user/ 8 * Version: 1. 28 * Version: 1.3 9 9 */ 10 10 11 11 function admin_add_user_adminpage() { 12 global $bbdb, $bb, $bb_table_prefix; 12 global $bbdb, $bb; 13 14 // get the default registration functions 15 require_once( BB_PATH . BB_INC . 'registration-functions.php'); 13 16 ?> 14 17 <h2><?php _e('Add New User') ?></h2> … … 20 23 if (empty($_POST['user_login'])) : 21 24 $admin_add_user_error['user_login'] = "<li><strong>ERROR</strong>: Please enter a username.</li>"; 22 elseif (bb_user_exists( user_sanitize($_POST['user_login'], true))) :25 elseif (bb_user_exists(sanitize_user($_POST['user_login'], true))) : 23 26 $admin_add_user_error['user_login'] = "<li><strong>ERROR</strong>: This username is already taken.</li>"; 24 27 endif; … … 36 39 if (!$admin_add_user_error) : 37 40 38 $now = bb_current_time('mysql'); 39 $user_login = user_sanitize( $_POST['user_login'], true ); 41 $user_login = $_POST['user_login']; 40 42 $user_email = $_POST['user_email']; 41 43 $user_url = bb_fix_link( $_POST['user_url'] ); 42 44 $password = $_POST['pass1']; 43 $passcrypt = md5( $password );44 45 45 $bbdb->query("INSERT INTO $bbdb->users 46 (user_login, user_pass, user_email, user_url, user_registered) 47 VALUES 48 ('$user_login', '$passcrypt', '$user_email', '$user_url', '$now')"); 46 if ( $user_id = bb_new_user( $user_login, $user_email, $user_url ) ) { 47 bb_update_user_password( $user_id, $password ); 48 49 bb_update_usermeta( $user_id, $bbdb->prefix . 'capabilities', array('member' => true) ); 50 51 if ($_POST['user_send_email']) : 52 /** 53 * Sending a mail again is bad, but if we don't do this, 54 * the user gets a wrong password sent. 55 * The bb_new_user() function can't be prevented from sending the first mail. 56 */ 57 $message = __("PLEASE IGNORE THE FIRST MAIL!\n\nYour username is: %1\$s \nYour new password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!"); 58 59 bb_mail( 60 $user_email, 61 bb_get_option('name') . ': ' . __('Password'), 62 sprintf( $message, $user_login, $password, bb_get_option('uri') ) 63 ); 64 endif; 49 65 50 $user_id = $bbdb->insert_id; 51 bb_update_usermeta( $user_id, $bb_table_prefix . 'capabilities', array('member' => true) ); 52 53 if ($_POST['user_send_email']) : 54 // why doesn't this work? 55 // bb_send_pass( $user_id, $password ); 56 57 $message = __("Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!"); 58 59 bb_mail( 60 bb_get_user_email( $user_id ), 61 bb_get_option('name') . ': ' . __('Password'), 62 sprintf( $message, "$user_login", "$password", bb_get_option('uri') ) 63 ); 64 endif; 65 66 do_action('bb_admin_new_user', $user_id, $password); 66 do_action('bb_admin_new_user', $user_id, $password); 67 } 67 68 68 69 $admin_add_user_success['user_login'] = "<li>User <strong>".$user_login."</strong> has been added. <a href=\"".get_profile_tab_link($user_id, 'edit')."\">Edit user's profile »</a></li>"; … … 141 142 function admin_add_user_adminnav() { 142 143 global $bb_submenu; 143 $bb_submenu['users.php'][] = array(__('Add User'), ' use_keys', 'admin_add_user_adminpage');144 $bb_submenu['users.php'][] = array(__('Add User'), 'administrate', 'admin_add_user_adminpage'); 144 145 } 145 146 add_action( 'bb_admin_menu_generator', 'admin_add_user_adminnav' );
