function byrd_new_user($user, $email, $role) { $_tbl =& bTable::getInstance('users', 'Table'); $i = ''; while (1 == 1) { $username = str_replace(' ', '', $user . $i); $user_id = $_tbl->username_exists($username); if (!$user_id) { $user_id = byrd_create_user($username, $email); $usermeta =& bTable::getInstance('usermeta', 'Table'); $usermeta->bind(array('user_id' => $user_id, 'meta_key' => 'word_capabilities', 'meta_value' => serialize(array($role => 1)))); $usermeta->store(); break; } if (!is_numeric($i)) { $i = 0; } $i++; } }
function byrd_new_user($user, $email, $role) { global $wpdb; $_tbl =& bTable::getInstance('users', 'Table'); $i = ''; while (1 == 1) { $username = str_replace(' ', '', $user . $i); $user_id = $_tbl->username_exists($username); if (!$user_id) { $created = byrd_create_user($username, $email); $user_id = $created['user_id']; $usermeta =& bTable::getInstance('usermeta', 'Table'); $usermeta->bind(array('user_id' => $user_id, 'meta_key' => $wpdb->prefix . 'capabilities', 'meta_value' => serialize(array($role => true)))); $usermeta->store(); break; } if (!is_numeric($i)) { $i = 0; } $i++; } return array('user_name' => $username, 'password' => $created['password'], 'userid' => $user_id); }