Huge Performance Improvements, CSS Units and More

Joomla Wesbite Builder Gridbox with Performance Improvements and CSS Units
Mon. - Fri. 9 am - 5 pm Ask a Question
Remember me

Php script for adding user to joomla database

2 years 10 months ago #1

  • sen's Avatar
  • sen
  • Posts: 14
Hi,
I am creating a user registration form for new joomla user registration and adding new fields. I am wondering how i can add a user using Balbooa Forms into our joomla database, together with an administrator activation? Is there a ready php script i can use or modify from?
Is there any way to do this?

2 years 10 months ago #2

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 26073
Hello,
Thank you for contacting us

Unfortunately, this is not possible

Best Regards,
Vyacheslav, Balbooa Support Team

2 years 10 months ago #3

  • sen's Avatar
  • sen
  • Posts: 14
Actually, it is possible. We just need the right php script calls. I did some investigation and for those who need this function into Balbooa's beautiful forms, you can modify the script below: (if you need to setup user activation by admin, its possible too, but the script below is for basic user insertion to joomla user db)

----
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$app = JFactory::getApplication('site');
$app->initialise();

/* you may want to change this*/
$params = array(
    'name'=>'test',
    'username'=>'test_user',
    'email'=>'mail@example.com',
    'password'=>'test',

);

$udata = array(
    'name'=>$params['name'],
    'username'=>$params['username'],
    'password'=>$params['password'],
    'email'=>$params['email'],
    'groups'=>array(2), // set the usergroup(s) here (id)

);

$user = new JUser;

try{
    echo '<pre>';
    echo 'Bind user data: ';
    var_dump($user->bind($udata));         

    echo 'Save user data: ';
    var_dump($user->save());

    echo 'Testing login: ';
    var_dump( $app->login( array('username'=>$params['username'],'password'=>$params['password']) ) );

} catch (Exception $ex) {

    echo 'Exception: ',  $e->getMessage(), '\n';

}

2 years 4 months ago #4

  • Stephan's Avatar
  • Stephan
  • Posts: 292
Hallo Sen,

Did you have any success in creating the login and registration form with Balbooa Forms?

Kind Regards

Stephan

2 years 1 month ago #5

  • Vanderlei Frari's Avatar
  • Vanderlei Frari
  • Posts: 94
Sen, where do you put this script? In button?
Powered by Kunena Forum