我有一个脚本,允许您使用php创建一个Joomla帐户。这就是它的样子:
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";
使用脚本时,用户已成功注册。我已启用用户激活,以便用户收到包含其帐户详细信息和激活URL的电子邮件。但是,当电子邮件发送时,电子邮件主题为“COM_USERS_EMAIL_ACCOUNT_DETAILS”,正文为“COM_USERS_EMAIL_REGISTERED_WITH_ACTIVATION_BODY”。我对Joomla很陌生,我无法弄清楚为什么发送这个而不是一封包含他们的帐户详细信息和激活URL的电子邮件。
答案 0 :(得分:5)
似乎没有加载语言(尽管我认为注册过程会这样做)。尝试查看this question/answer,看看添加以下代码是否有帮助。
$language = JFactory::getLanguage();
$language->load('com_users', JPATH_SITE);