I am looking for a template file that would enable me to modify the content of the email sent to an admin when a new user registers. Specifically I want to include some of the data entered into Jomsocial custom profile fields when the user registered in the email sent to the Admin. This will help the Admin decide whether to approve them or not.
So 2 questions:
1: Where is the template file to modify?
2. Can you provide example syntax of how to reference the custom profile fields in the email?
Thanks!
(Joomla 2.5.19, Jomsocial 3.1.0.4)
Hi Keith,
You can modify the text of email notification from this file language/en-GB/en-GB.com_community.ini
COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION="Hello %s,\n\nThank you for registering at %s. Your account details are as follows:\n\nUsername: %s\nPassword: %s\n\nOnce you have completed the rest of registration process, you will receive another email with an activation link."
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION', $name, $sitename, $username, $password);
Thanks for the info Dimas.
In the file you mentioned I have found the following on line 1870:
COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL="Hello %s,\n\nA new user has registered at %s. Another email will be sent for your approval once the user has verified his or her email. \nThis e-mail contains the details:\n\nName: %s\nE-mail: %s\nUsername: %s\n\nPlease do not respond to this message. This message is automatically generated and is sent for your information only."
But I don't see how to insert a custom field from the user's profile. If I have a custom field called CITY then would I do this?
COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL="Hello %s,\n\nA new user has registered at %s. Another email will be sent for your approval once the user has verified his or her email. \nThis e-mail contains the details:\n\nName: %s\nE-mail: %s\nUsername: %s\nCity: $cuser->getInfo('FIELD_CITY');\nPlease do not respond to this message. This message is automatically generated and is sent for your information only."
sample you the code like this (I add location field) :
$message = JText::sprintf('COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION', $name, $sitename, $username, $password, $location);
COM_COMMUNITY_EMAIL_REGISTRATION_ACCOUNT_DETAILS_REQUIRES_ACTIVATION="Hello %s,\n\nThank you for registering at %s. Your account details are as follows:\n\nUsername: %s\nPassword: %s\n\n Location: %s\n\nOnce you have completed the rest of registration process, you will receive another email with an activation link."
I made the following changes. The change to en-GB.com_community.ini caused the new labels to show up in the email. However, the change to register.php DID NOT cause the custom profile field values to get passed into the email. I am using the Field Code names of the profile fields in register.php.
register.php Line 924:
$message2 = JText::sprintf( JText::_( 'COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL' ), $row->name, $sitename, $name, $email, $username, $street, $city, $state, $postal, $why, $referral);
en-GB.com_community.ini Line 1124:
COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL="Hello %s,\n\nA new user has registered at %s. Another email will be sent for your approval once the user has verified his or her email. \nThis e-mail contains the details:\n\nName: %s\nE-mail: %s\nUsername: %s\nStreet: %s\nCity: %s\nState: %s\nZip: %s\nWhy?: %s\nReferred By: %s\n\nPlease do not respond to this message. This message is automatically generated and is sent for your information only."
The email looks like:
Hello Web Admin,
A new user has registered at My Website. Another email will be sent for your approval once the user has verified his or her email.
This e-mail contains the details:
Name: Paul Smith
E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Username: pauls
Street:
City:
State:
Zip:
Why?:
Referred By:
Please do not respond to this message. This message is automatically generated and is sent for your information only.
$cUser = CFactory::getUser($userId)
That makes sense. However, it doesn't seem to work.
Here is my register.php code:
//Send notification email to administrators
foreach ($rows as $row)
{
if ($row->sendEmail)
{
if ($requireApproval)
{
$cUser = CFactory::getUser($user->id);
$street= $cUser->getInfo('street');
$city = $cUser->getInfo('city');
$state = $cUser->getInfo('state');
$postal = $cUser->getInfo('postal');
$why = $cUser->getInfo('why');
$referral = $cUser->getInfo('referral');
$message2 = JText::sprintf( JText::_( 'COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL' ), $row->name, $sitename, $name, $email, $username, $street, $city, $state, $postal, $why, $referral);
COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL="Hello %s,\n\nA new user has registered at %s. Another email will be sent for your approval once the user has verified his or her email. \nThis e-mail contains the details:\n\nName: %s\nE-mail: %s\nUsername: %s\nStreet: %s\nCity: %s\nState: %s\nZip: %s\nWhy?: %s\nReferred By: %s\n\nPlease do not respond to this message. This message is automatically generated and is sent for your information only."
Hi Keith,
I think "$user->id" variable is empty, you need to find way how to get "$user->id" from the newest registration user.. I cant help you too much this.. this is your challange ;)
Good luck!
There was not a space in register.php here: $street=
I added a space: $street =
and it is all working now. Just a typo. I wouldn't think it would matter in PHP, but who knows, maybe it was a cache thing.
Hopefully this helps others!