fatal error: JPluginHelper in my standalone application

756 views
Skip to first unread message

Sean Conway

unread,
Aug 3, 2011, 9:18:50 AM8/3/11
to joomla-de...@googlegroups.com
i am adding users to joomla from another script, i have it working for the most part but i am getting this:
Fatal error: Class 'JPluginHelper' not found in /libraries/joomla/user/user.php on line 669

if i comment line 669 in user.php no error is given and the user is successfully added.

here is the code i am using to add the user.

[code]
$joomla_install = "/home/smc/public_html/joomlatest";
define( '_JEXEC', 1 );
define('JPATH_BASE', $joomla_install );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
$mainframe =& JFactory::getApplication('site');
jimport( 'joomla.user.helper' );
$user['fullname'] =  $vars["firstname"] ." ". $vars["lastname"];
$user['email'] = $vars["email"];
$user['username'] =  $vars["email"];
$password  = $vars["password"];

$salt = JUserHelper::genRandomPassword(32);
            $crypt = JUserHelper::getCryptedPassword($password, $salt);
            $password = $crypt.':'.$salt;

$instance = JUser::getInstance();
$config = JComponentHelper::getParams('com_users');
$defaultUserGroup = $config->get('new_usertype', 2);
$acl = JFactory::getACL();

$instance->set('id', 0);
$instance->set('name', $user['fullname']);
$instance->set('username', $user['username']);
$instance->set('password', $password);
$instance->set('email', $user['email']);
$instance->set('usertype', 'deprecated');
$instance->set('groups', array($defaultUserGroup));


        if ($instance->save())
{
$newUser =& JFactory::getUser($user['username']);

}
        else {
return JError::raiseWarning('SOME_ERROR_CODE', $instance->getError());
        }
}
[/code]

Mark Dexter

unread,
Aug 3, 2011, 9:46:48 AM8/3/11
to joomla-de...@googlegroups.com
Have you tried to require_once base+libraries/joomla/plugin/helper.php? Also, my understanding is that it is preferable to minimize the use of require_once and, where possible, use JLoader::register(), jimport, or JLoader::import(). In this case, I think you could use JLoader::import('joomla.plugin.helper').

Good luck. Mark

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

Sean Conway

unread,
Aug 3, 2011, 11:14:31 AM8/3/11
to joomla-de...@googlegroups.com
much appreciated, "require_once base+libraries/joomla/plugin/helper.php" fixed the Fatal Error,
i will need to look into your other suggestion as far as how to use JLoader,
JLoader::import('joomla.plugin.helper') gave me a similar Fatal Error but in my code.

thank you for the quick and useful reply!

Sean
Reply all
Reply to author
Forward
0 new messages