I have a script that will successfully register a user on my Joomla site via an external script.
The code is below;
<?php 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); $username = 'adam'; $name = 'adam24'; $email = 'email@example.com'; $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); ?>
This creates a new user, adds the to the specified group, and sends them an email.
I am using this script on a subdomain of my joomla site –
I have the registration email set to
self, so after registration the user will receive an email with a link to activate their account.
The issue is that the email body contains a link to my sub domain and not the root site. So the link is broken. The email body is as follows;
Thank you for registering at Apps Localhost. Your account is created
and must be activated before you can use it. To activate the account
select the following link or copy-paste it in your browser:
After activation you may login to http://apps.example.local/
using the following username and password:
Clicking this link results in a
Internal Server Error. Which is correct because that location doesn’t exist on my subdomain.
I want to redirect the users to
http://apps.example.local/login and display a message like;
Your account is now active and you can login.
What do I need to change in order to get this working?