Skip to main content
2 of 2
added 33 characters in body
jonboy
  • 3.6k
  • 25
  • 53

Language Constant Not Displaying in External Script

Joomla 3.9.14

I have an external application that uses the script below, allowing users to register as a user on my Joomla site. It all appears to be working apart from error displaying. My code is below;

register.php

<?php 
// database connection
include('conn.php');

require_once JPATH_BASE .'/components/com_users/models/registration.php';

$model = new UsersModelRegistration();

jimport('joomla.mail.helper');
jimport('joomla.user.helper');

$language = JFactory::getLanguage();
$language->load('com_users', JPATH_SITE);

// hard coded for now, in live site these will be $_POST values
$username = 'adam';
$name = 'adam24';
$email = '[email protected]';
$password = 'password';

$data = array( 
    'username' => $username,
    'name' => $name,
    'email1' => $email,
    'password1' => $password, // First password field
    'password2' => $password, // Confirm password field
    'groups'    =>array('10'),
    'block' => 0 );

echo $model->register($data);
?>

When I visit this page, the user is created in my Joomla site with the correct details. When I visit the page for a second time I get an error about the username already being is use, this is expected. However when I dump the error it is displayed as;

$err = $model->get('_errors');

// result of var_dump($err)
array (
  0 => 'Joomla\\CMS\\Form\\Form::getInstance() could not load file',
  1 => 'Registration failed: JLIB_DATABASE_ERROR_USERNAME_INUSE',
) 

The JLIB_DATABASE_ERROR_USERNAME_INUSE constant isn't loading - why would this be?

It's defined at administrator\language\en-GB\en-GB.lib_joomla.ini

jonboy
  • 3.6k
  • 25
  • 53