• 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: Help with admin email syntax

Help with admin email syntax 3 years 1 week ago #42006

  • duncan
  • duncan's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
  • Thank you received: 1
Hi,

I am working on a project feedback form.

Customers are asked to give a rating for a project of 1-10. I have set this up as a radio button field.

When the form is submitted I want to change the subject and add a cc address if the project rating is 5 or less.

I have adapted some of the code found in this article: www.rsjoomla.com/support/documentation/r...p-email-scripts.html

I worked out how to change the subject using the following code.
$modAdminEmailSubject = $form->AdminEmailSubject;
 
    if($_POST['form']['project-rating'] < 5)
      $modAdminEmailSubject .= ': Low rating';
 
    else $modAdminEmailSubject .= '';
 
    $adminEmail['subject'] = $modAdminEmailSubject;

Now I'm not a coder, but thought maybe I can adapt the above code to also add the cc address if the rating is below 5.

Initially it was working, but it was sending to the cc address whether the rating was high or low.

I'm sure my code needs some tweaking to make the syntax correct, but I lack the skills to know what to add/change.

If anybody could take a look at the code below and let me know where I'm going wrong I would be grateful. The error I am currently getting is: syntax error, unexpected 'else' (T_ELSE), expecting end of file
$modAdminEmailSubject = $form->AdminEmailSubject;
  $modAdminEmailcc = $form->AdminEmailcc;
 
    if($_POST['form']['project-rating'] < 5)
      $modAdminEmailSubject .= ': Low rating';
      $adminEmailcc .= 'myemailaddress';
 
    else $modAdminEmailSubject .= '';
            $adminEmailcc .= '';
 
    $adminEmail['subject'] = $modAdminEmailSubject;
$adminEmail[cc] = $adminEmailcc;
Last Edit: 3 years 4 days ago by duncan.
The administrator has disabled public write access.

Help with admin email syntax 3 years 2 days ago #42015

  • duncan
  • duncan's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
  • Thank you received: 1
I found the solution to the problem, via help from this post: www.rsjoomla.com/forum/37-rsform-pro/294...dditional-email.html

All that was required was to add && between my two if statements.

Code now looks like this:
$modAdminEmailSubject = $form->AdminEmailSubject;
  $modAdminEmailcc = $form->AdminEmailcc;
 
    if($_POST['form']['project-rating'] < 5)
      $modAdminEmailSubject .= ': Low rating'; && $adminEmailcc .= 'myemailaddress';
 
    else $modAdminEmailSubject .= '';
            $modAdminEmailcc .= '';
 
    $adminEmail['subject'] = $modAdminEmailSubject;
$adminEmail[cc] = $modAdminEmailcc;
Last Edit: 3 years 2 days ago by duncan.
The administrator has disabled public write access.

Help with admin email syntax 3 years 2 days ago #42016

  • duncan
  • duncan's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 19
  • Thank you received: 1
OK, sorry to keep going on about this, but I’ve got an update on the above.

With the above code the cc email is received if the project rating is below 5, great, but I’ve since realised the subject line isn’t appended correctly. Instead of adding to my exisiting subject line and saying "Project Rating :low rating" it's putting a 1 at the end of my subject line, so subject line says "Project Feedback1".

I feel like it's just a small tweak to get the above code to work, if anybody has any ideas that would be great.

In the meantime, I have found a solution that does work and it does exactly what I want it to do, but it seems a bit convoluted, ie I feel like the code could be more efficient - so again any ideas on this would be great.

Here's the updated version:
$modAdminEmailSubject = $form->AdminEmailSubject;
  $modAdminEmailcc = $form->AdminEmailcc;
 
    if($_POST['form']['project-rating'] < 5)
      $modAdminEmailSubject .= ' :low rating';
 
    else $modAdminEmailSubject .= '';
 
   if($_POST['form']['project-rating'] < 5)
      $modAdminEmailcc .= ' myemailaddress';
 
else $modAdminEmailcc .= '';
 
 
    $adminEmail['subject'] = $modAdminEmailSubject;
$adminEmail[cc] = $modAdminEmailcc;
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!