Notes by JDeveloper for JDeveloper
Once you master it, you're gonna like it

Login Joomla User with Joomla API

Written by Viktor Iwan

At sometime, you need to have your script to login a user via joomla API. Here's how:

function loginJoomlaUser($username,$password,$return=""){
              $app = JFactory:: getApplication();
              $options = array();
              $options[ 'remember'] = JRequest::getBool( 'remember', false );
              $options[ 'return'] = $return;
              $credentials = array();
              $credentials[ 'username'] = $username;
              $credentials[ 'password'] = $password;
              $err = $app->login($credentials, $options);

Add Joomla User Programmatically with Joomla API

Written by Viktor Iwan

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(
                            "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 ;

Connect to other Database (External) in Joomla

Written by Viktor Iwan

When you want to connect other external database from your current project:

$conf =& JFactory::getConfig();
$host 		= ''; //replace your IP or hostname
$user 		= 'db_user'; //database user
$password 	= 'db_pass';//database password
$database	= 'db_name'; //database name
$prefix 	= 'jos_'; //prefix if any else just give any random value
$driver 	= 'mysql'; //here u can also have ms sql database driver, postgres, etc
$debug 		= $conf->getValue('config.debug');
$options	= array ( 'driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix );

$db =& JDatabase::getInstance( $options );

//Do the rest of process (queries) like usual