I know.
I have checked all the fields, but the error is the same.
Code:
/* Load Joomla */
define('_JEXEC', 1); /* JPATH_BASE and JPATH_CB is defined more up, but is correct */
require( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require( JPATH_BASE .DS. 'libraries' .DS. 'import.php');
$mainframe = \JFactory::getApplication('site');
require_once (JPATH_BASE.DS.'includes'.DS.'framework.php');
include_once( JPATH_CB . '/components/com_comprofiler/plugin.foundation.php' );
cbimport( 'cb.plugins' );
cbimport( 'cb.html' );
cbimport( 'cb.database' );
cbimport( 'language.front' );
cbimport( 'cb.snoopy' );
cbimport( 'cb.imgtoolbox' );
global $_CB_framework, $mainframe, $_PLUGINS, $_CB_database, $ueConfig;
// check user
$_CB_database->setQuery( "SELECT username FROM #__users WHERE username = '$checkusername'");
$usern = $_CB_database->loadResult();
if ($usern) {
return "El usuario ya está dado de alta en la provincia." ;
}
// API CB register user
$approval = ( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve );
$confirmation = ( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm );
$usertype = $_CB_framework->getCfg( 'new_usertype' );
$user = new \moscomprofilerUser( $_CB_database );
$user->usertype = ( $usertype ? $usertype : 'Registered' );
$user->gid = $_CB_framework->acl->get_group_id( $user->usertype, 'ARO' );
$user->gids = array( $user->gid );
$user->sendEmail = 0;
$user->registerDate = date( 'Y-m-d H:i:s', $_CB_framework->now() );
$user->name = 'usuname';
$user->firstname = 'usufirst';
$user->lastname = 'usulast';
$user->username = 'usuuser';
$user->email = 'prueba@prueba.es';
$user->password = 'asdfasdf' ;
$user->registeripaddr = '0.0.0.0';
if ( $approval == 0 ) {
$user->approved = 1;
} else {
$user->approved = 0;
}
if ( $confirmation == 0 ) {
$user->confirmed = 1;
} else {
$user->confirmed = 0;
}
if ( ( $user->confirmed == 1 ) && ( $user->approved == 1 ) ) {
$user->block = 0;
} else {
$user->block = 1;
}
if ( ( $user->confirmed == 1 ) && ( $user->approved == 1 ) ) {
$user->block = 0;
} else {
$user->block = 1;
}
$_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$user, &$user ) );
if ( $user->store() ) {
if ( ( $user->confirmed == 0 ) && ( $confirmation != 0 ) ) {
$user->_setActivationCode();
if ( ! $user->store() ) {
return false;
}
}
$_PLUGINS->trigger( 'onAfterUserRegistration', array( &$user, &$user, true ) );
return true;
}
else{
echo $user->getError();
}