So, you code your extension OR use seblod template and you would like to add a user directly from your codes. Here's how:

function addJoomlaUser($username, $name, $email, $password) {
              jimport( 'joomla.user.helper');
       
              $data = array(
                            "name"=>$name,
                            "username"=>$username,
                            "password"=>$password,
                            "password2"=>$password,
                            "email"=>$email,
                            "block"=>0,
                            "groups"=>array ("1" ,"2" )
              );
       
              $user = new JUser;
               if(!$user->bind($data)) {
                      throw new Exception("Could not bind data. Error: " . $user->getError());
              }
               if (!$user->save()) {
                      throw new Exception("Could not save user. Error: " . $user->getError());
              }
               return $user->id ;
       }
Trackback URL: