1. FranioBed
  2. General
  3. Monday, October 22 2018, 12:16 PM
Hello,

I would like to display the easy profile custom fields in the administrator activation email. I've tried adding the custom fields in \components\com_users\models\registration.php file and overriding the COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY language value to incorporate them, but this doesn't work, the custom value is a missing string. I think that core Joomla! doesn't recognise easy profile custom values, or sees them under another name than the alias listed in easy profile comoponent.
Is this even the correct way to do this? Is there another solution? Should I maybe use an another plugin? I've looked into AcyMailing, but I'm not sure it would work with easy profile and i don't want to buy it unless i'm certain.
Accepted Answer
admin Accepted Answer
Admin
ok then please try with this:
require_once(JPATH_SITE.'/components/com_jsn/helpers/helper.php'); /* Load Library */
$emailBody = JText::sprintf(
'COM_USERS_EMAIL_ACTIVATE_WITH_ADMIN_ACTIVATION_BODY',
$data['sitename'],
$data['name'],
$data['email'],
$data['username'],
JsnHelper::getUser($user->id)->city_name, /* Load field value */
$data['activate']
);
  1. more than a month ago
  2. General
  3. # Permalink
admin Accepted Answer
Admin
Hi,
I've tried adding the custom fields in \components\com_users\models\registration.php

can you please provide me your modifications to understand how you have done this?

Suggestion:
I think that edit a Joomla core file is dangerous and with Joomla updates you will lose your modifications, the best way is to send a second email to the administrator without changing core files. To do this you can build a simple plugin, for example:
- Download (at the end of docs page at http://docs.easy-profile.com/index.php/article/triggers ), install and enable (Extensions->Plugins) skeleton plugin
- Open the edit the file at /plugins/jsn/skeleton/skeleton.php
- Replace entire code with this
<?php

defined('_JEXEC') or die;

class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user, $data, $changed, $isNew)
{
if($isNew)
{
$body=$user->name." updated user profile. \n\n";
foreach($changed as $fieldalias){
$body.=$fieldalias .": ". $data[$fieldalias] ."\n";
}
$config = JFactory::getConfig();
$result=JFactory::getMailer()->sendMail(
$config->get( 'mailfrom' ), // Sender Mail
$config->get( 'fromname' ), // Sender Name
'[email protected]', // Receiver Mail
'New User', // Subject Mail
$body // Body Mail
);
}
}
}
IMPORTANT: Replace [email protected] with email of receiver
  1. more than a month ago
  2. General
  3. # 1
FranioBed Accepted Answer
Basic
Content Protected
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
Hi,
try with:
$data['sitename'],
$data['name'],
$data['email'],
$data['username'],
JsnHelper::getUser($user->id)->city_name, //added this line, city_name is custom value alias from easy profile
$data['activate']


By the way, do you know if using AcyMailing would work with easy profile custom fields?
Probably yes but I'm not sure :(
  1. more than a month ago
  2. General
  3. # 3
FranioBed Accepted Answer
Basic
Unfortunately, it doesn't work. I get an error: Class 'JsnHelper' not found
  1. more than a month ago
  2. General
  3. # 4
FranioBed Accepted Answer
Basic
Content Protected
  1. more than a month ago
  2. General
  3. # 5
admin Accepted Answer
Admin
great, you can find references about my code at http://docs.easy-profile.com/index.php/article/jsnuser-object
  1. more than a month ago
  2. General
  3. # 6
cristianbravo Accepted Answer
Pro
Hi i have tried the solution but no emails get sent. i modified the code to that one above but nothing happends when user updates their profile either custom fields or native fields. please help
  1. more than a month ago
  2. General
  3. # 7
admin Accepted Answer
Admin
Hi @Alpha,
if you need to receive an email when user edit own profile then you can try to see this topic: https://easy-profile.com/support/email-to-admin-if-profile-fields-change.html#reply-24646
  1. more than a month ago
  2. General
  3. # 8
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.