From 629be481967c1cdb3ab78da2fcf5ee2350b3883b Mon Sep 17 00:00:00 2001 From: Karsten Heiken Date: Tue, 17 Jul 2012 13:50:23 +0200 Subject: [PATCH] Fix bug when creatig a new user When creating a new user, there is no data set for the users_settings table. This results in a JavaScript error that prevents the site from working correctly. --- application/models/user.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/application/models/user.php b/application/models/user.php index 59c743b..c40955d 100644 --- a/application/models/user.php +++ b/application/models/user.php @@ -296,7 +296,18 @@ class User extends CI_Model { $this->db->insert('users', array_merge($data, $additionalData)); - return $this->db->affected_rows() > 0 ? $data['id'] : false; + $user_created = $this->db->affected_rows() == 1; + + if($user_created) { + // set the initial user settings + $settings['user_id'] = $data['id']; + $settings['jobs_check_interval'] = 5; + + $this->db->insert('users_settings', $settings); + return true; + } + + return false; } /**