1

So i'm using kohana user module, and i would like to extend my register page, now it adds username, email, and password but i would like to add some extra fields, and i just can't find where can i do it.

I found function action_register which leads to Auth::instance()->register($_POST, true); so i found this function register($fields) which leads to $user = ORM::factory('user'); and $user->create_user($fields, array() so i'm stuck somewhere here, i'm not even sure if i'm going the right path...

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
Linas
  • 4,380
  • 17
  • 69
  • 117

1 Answers1

3

Just create user.php file under application/classes/model folder and put this inside:

<?php

defined('SYSPATH') or die('No direct access allowed.');

class Model_User extends Model_Auth_User
{
   public function create_user($values, $expected)
   {
      // Your definition of the function
   }
}

After checking the register function, here is the place for other fields (line 22-27):

$user->create_user($fields, array(
                                'username',
                                'password',
                                'email',
                                'user_type',
                                'other field',
                                'other field2',
                        ));

Of course you'll need to have other_field and other_field2 exist in your table.

matino
  • 17,199
  • 8
  • 49
  • 58
  • This is completely wrong, i already have everything fylly completed i just need to find where the actual query is executed so i could add extra fields – Linas Dec 22 '11 at 15:32
  • Exnted the `create_user` function then if you already got everything flying? – matino Dec 22 '11 at 15:35
  • that function looks like this http://pastebin.com/fqk61PH7 and it makes no sense to me.. – Linas Dec 22 '11 at 15:41
  • It makes perfect sense. It creates a user by calling ORM functions - first values, then create. It also checks if password is not empty. I suggest you go through the ORM tutorial to get the basics. – matino Dec 22 '11 at 15:46
  • okay so how do i send extra values, because i already created new fields in databse i just need to add those values – Linas Dec 22 '11 at 15:49
  • You need to show your `Auth::instance()->register` function but basically you should just pass the `$_POST` and expected array – matino Dec 22 '11 at 15:54
  • here it is, http://pastebin.com/eBQb5aJW i added `user_type`, but it doesn't do the trick – Linas Dec 22 '11 at 15:57
  • Never mind, i've tried reseting everything and did it again, and it finaly works after 10h of failing it works ;d thanks for your help – Linas Dec 22 '11 at 16:01