• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Change email subject and body message

Change email subject and body message 9 years 6 months ago #32932

  • pavle
  • pavle's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
I need to send different email content to the same user, depending on the change in Directory field.
Seems obviousto use PHP script called before the Directory Emails, to alter subject and message. I couldn't make it. Is this the right approach? An example would be highly appreciated.
The administrator has disabled public write access.

Change email subject and body message 9 years 3 months ago #33724

I also need this does any one did that
The administrator has disabled public write access.

Change email subject and body message 9 years 3 months ago #33731

has any one figured out how to do it?
The administrator has disabled public write access.

Change email subject and body message 9 years 3 months ago #33732

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
pavle wrote:
I need to send different email content to the same user, depending on the change in Directory field.
Seems obviousto use PHP script called before the Directory Emails, to alter subject and message. I couldn't make it. Is this the right approach? An example would be highly appreciated.

Yes, this is the right approach. Can you post your script here... ? Perhaps others can improve it.
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
The administrator has disabled public write access.

Change email subject and body message 9 years 3 months ago #33736

  • pavle
  • pavle's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
In the meanwhile, I solved the prolem. Here is how i did it:

Directory e-mails are sent after (directory) form is submited and data stored in database.

Basically, I retrieve the user submitted vaule to a variable $Status. Depending on the value of $Status, I change $directoryEmail variable which controls what is sent and to whom.

In this example user submitted a value for the database field named 'Status'. The value of that field can be either 'Approved' or 'Rejected'.

Note that setting $directoryEmail to nothing will prevent sending Directory e-mail.
// get the value of a database field Status and store it in variable $Status
$db = JFactory::getDbo();
$db->setQuery("SELECT  FieldValue FROM `#__rsform_submission_values`
        WHERE `SubmissionId`='".$SubmissionId."' AND `FieldName`='".'Status'."'");
$Status= $db->loadResult();
 
// check the value of $Status and set $directoryEmail component accordingly
if($Status == 'Approved'){
	$directoryEmail['text'] = 'text when approved...';
	$directoryEmail['subject'] = 'subject when approved';
	$directoryEmail['to'] = 'user email'; 
 
} elseif($Status == 'Rejected'){
	$directoryEmail['text'] = 'text when rejected...';
	$directoryEmail['subject'] = ' subject when rejected ';
	$directoryEmail['to'] = 'user email';
 
} else {
	$directoryEmail['to'] = '';
 
}
Last Edit: 9 years 3 months ago by alexp.
The administrator has disabled public write access.
The following user(s) said Thank You: alexp

Change email subject and body message 9 years 3 months ago #33737

  • pavle
  • pavle's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 1
Please note that code in this example is not displayed correctly, probably because editing software is interpreting sqaure brackets as special characters.

Variable $directoryEmail is missing 'text', 'to' and 'subject' parts, all in square brackets.
Last Edit: 9 years 3 months ago by pavle.
The administrator has disabled public write access.

Change email subject and body message 9 years 3 months ago #33755

With help of Andrei ive managed the problem and now when user select value ODRZUCONA in drop down menu, there will be send only email1 if he select value ZAAKCEPTOWANA there will be send only email2
if($_POST['form']['dropdownfieldvalue'][0] == 'Odrzucona') 
 
{
   if($directoryEmail['subject'] == 'email1') {
   $user = JFactory::getUser($_POST['form']['dropdownfieldvalue'][0]);
   $directoryEmail['to'] = $user->email;
   $directoryEmail['cc'] = 'emailadress';
   }
 
   if($directoryEmail['subject'] == 'email2') {
        $directoryEmail['to'] = '';
        $directoryEmail['from'] = '';
        }
 
}
 
if($_POST['form']['dropdownfieldvalue'][0] == 'Zaakceptowana') 
 
{
   if($directoryEmail['subject'] == 'email1') {
   $directoryEmail['to'] = '';
   $directoryEmail['from'] = '';
   }
 
   if($directoryEmail['subject'] == 'email2') {
        $user = JFactory::getUser($_POST['form']['dropdownfieldvalue'][0]);
        $directoryEmail['to'] = $user->email;
        $directoryEmail['cc'] = 'emailadres';
        }
 
}
Last Edit: 9 years 3 months ago by alexp. Reason: missing code tags
The administrator has disabled public write access.

Change email subject and body message 9 years 3 months ago #33756

well in my post i ve made mistake here:
$user = JFactory::getUser($_POST['form']['dropdownfieldvalue'][0]);
   $directoryEmail['to'] = $user->email;

does anyone can help me to make that after editing field Director view, email will be send to the subbmiter of the form?
Last Edit: 9 years 3 months ago by alexp.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!