Chuck Hotaling
Chuck Hotaling

Reputation: 97

Joomla Activation Email via custom registration is not resolving language string

I have a script that allows you to create a Joomla account using php.This is what it looks like:

     define( '_JEXEC', 1 );
     define('JPATH_BASE', dirname(__FILE__) );
     define( 'DS', DIRECTORY_SEPARATOR );
     /* Required Files */
     require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
     require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

     $app = JFactory::getApplication('site');
     $app->initialise();
     require_once(JPATH_BASE.DS.'components'.DS.'com_users'.DS.'models'.DS.'registration.php');

     $model = new UsersModelRegistration();
     jimport('joomla.mail.helper');
     jimport('joomla.user.helper');

     $username = $_GET['username'];
     $name = $_GET['name'];
     $email = $_GET['email'];
     $password = $_GET['password'];
     $data = array( 'username' => $username,
     'name' => $name,
     'email1' => $email,
     'password1' => $password, // First password field
     'password2' => $password, // Confirm password field
     'block' => 0 );
      echo $model->register($data);
      echo "Registration Successful";

The user is registered successfully when I use the script. I have user activation turned on so that the user will get an email with their account details and an activation URL. However, when the email sends, the email subject is "COM_USERS_EMAIL_ACCOUNT_DETAILS" and the body is "COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY". I'm pretty new to Joomla and I can't figure out why it is sending this rather than an email with their account details and activation URL.

Upvotes: 1

Views: 480

Answers (1)

GDP
GDP

Reputation: 8178

It appears that the language isn't being loaded (though I would have thought the registration process would have done that). Try looking at this question/answer and see if adding the below code helps.

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

Upvotes: 5

Related Questions