By Tim Hunt on Monday, 05 February 2018
Posted in General Issues
Replies 9
Likes 0
Views 841
Votes 0
Hi there,

When overriding the email template files (e.g. for the moderation approval template) is there a way to include additional profile fields for the relevant account?

As part of the registration process I'm setting up for our site we have a couple of custom fields (organisation, reason for access) and I'd like to have these included in the moderation email sent to the admin email for approval, so that they can be reviewed and approved/rejected without needing to log into the backend.

I can see the username and email are just being accessed as $username and $email in the email template so I'm not sure how I would bring in the other profile fields.

Many thanks
Tim
Hey Tim,

Unfortunately it isn't possible to send all these data to the mail template but if you hack the model file in /administrator/components/com_easysocial/models/registration.php at line 806, you can push variables here,

[gist]
// Push arguments to template variables so users can use these arguments
$params = array(
'site' => $jConfig->getValue('sitename'),
'username' => $data['username'],
'password' => $data['password'],
'firstName' => !empty($data['first_name']) ? $data['first_name'] : '',
'middleName' => !empty($data['middle_name']) ? $data['middle_name'] : '',
'lastName' => !empty($data['last_name']) ? $data['last_name'] : '',
'name' => $user->getName(),
'avatar' => $user->getAvatar(SOCIAL_AVATAR_LARGE),
'profileLink' => $profileLink,
'email' => $user->email,
'activation' => FRoute::controller('registration' , array('external' => true , 'task' => 'activate' , 'activation' => $user->activation)),
'reject' => FRoute::controller('registration' , array('external' => true , 'task' => 'rejectUser' , 'id' => $user->id , 'key' => $key)),
'approve' => FRoute::controller('registration' , array('external' => true , 'task' => 'approveUser' , 'id' => $user->id , 'key' => $key)),
'manageAlerts' => false,
'profileType' => $profile->get('title')
);
[/gist]


For instance, if you want to pass the variable $hello into the e-mail template, you could do

[gist]
'hello' => $user->getFieldValue('SOME_CUSTOM_FIELD')
[/gist]
·
Monday, 05 February 2018 22:39
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark

Many thanks for the quick reply as always. I couldn't get it working with getFieldValue (oddly clicking submit on the registration form would load the e-mail template in the browser up to the point the custom field should have been inserted - after some extra fiddling this seemed to be happening only when it was loading a valid field kay in the model). However I saw an older post on here mentioning getFieldData - tried that instead and it worked perfectly as intended.

It's probably something to do with how I've configured the field (though it's just a standard textbox, no privacy or regex validation going on) or if getFieldValue loads an array rather than a string, but anyway it's set up and working nicely now so many thanks for all your help

Many thanks
Tim
·
Sunday, 11 February 2018 00:48
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Tim,

However I saw an older post on here mentioning getFieldData - tried that instead and it worked perfectly as intended.

Yes, this function can be userd as well, where it get the custom field raw data from the user

It's probably something to do with how I've configured the field (though it's just a standard textbox, no privacy or regex validation going on) or if getFieldValue loads an array rather than a string, but anyway it's set up and working nicely now so many thanks for all your help

Thanks for the heads up on this Tim, glad you are manage to set up it correctly
·
Monday, 12 February 2018 13:00
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi, will this work in ES4?
·
Thursday, 29 April 2021 03:06
·
0 Likes
·
0 Votes
·
0 Comments
·
Yep it will work with ES 4 as well
·
Thursday, 29 April 2021 10:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks Mark,

How can I echo the profile type title in the email have tried this but it did not work

<?php echo 'Profile Type'; ?>: <?php echo $profile; ?>						
·
Thursday, 29 April 2021 20:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Got it to work with:


<?php echo 'Profile Type'; ?>: <?php echo $profileType;?>
·
Thursday, 29 April 2021 21:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Got it to work with:


<?php echo 'Profile Type'; ?>: <?php echo $profileType;?>


Yes would be nice to have this info in emails maybe Stackideas can implement it too.

Which emails do you use it for?
·
Friday, 30 April 2021 15:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Which emails do you use it for?

You can use this in the following email template files :

JoomlaFolder/components/com_easysocial/themes/wireframe/emails/registration/moderator.approvals.php
JoomlaFolder/components/com_easysocial/themes/wireframe/emails/registration/moderator.auto.php
JoomlaFolder/components/com_easysocial/themes/wireframe/emails/registration/moderator.login.php
JoomlaFolder/components/com_easysocial/themes/wireframe/emails/registration/moderator.verify.php
·
Monday, 03 May 2021 10:27
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post