This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Auto Reply
#1

First I need to explain that I am using this script for "Reviews", not comments in general. So, with that said:

When a visitor of the site leaves a review, I would like an auto-reply to be sent to the reviewer (containing their review - like admin gets) and a message (Perhaps special offers, etc.) from the site. Admin already gets a notification, so I "think" this is doable.

It would be nice if the admin had the ability to customize this message so I would not have to change it for him every time he wanted to change the message though :-)

Note: The reviewer will NOT be making lots of reviews (MAYBE once a year) so getting an auto-reply message will not be a problem.

Thanks in advance!!
Reply
#2

This wouldn't be too difficult.

1. First you'd create a new email text file in /includes/emails/.

2. Then in /includes/app/processor.php you'd find the following line:

PHP Code:
<?php 
cmtx_notify_admin_new_comment_okay
($cmtx_name, $cmtx_comment, $cmtx_comment_id); //notify admin of new comment

And add this line below it:

PHP Code:
<?php 
cmtx_notify_user_new_comment
($cmtx_name, $cmtx_email, $cmtx_comment, $cmtx_comment_id); //notify user of new comment

3. Then in /includes/functions/processor.php you'd add this function. Make sure to change the path to the email file to the one you created.

PHP Code:
<?php 
function cmtx_notify_user_new_comment ($poster, $email, $comment, $comment_id) { //notify user of new comment

    global $cmtx_mysql_table_prefix, $cmtx_path; //globalise variables

    if (file_exists($cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/custom/new_comment_okay.txt')) {
        $admin_new_comment_okay_email_file = $cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/custom/new_comment_okay.txt'; //build path to custom admin new comment okay email file
    } else {
        $admin_new_comment_okay_email_file = $cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/new_comment_okay.txt'; //build path to admin new comment okay email file
    }

    $body = file_get_contents($admin_new_comment_okay_email_file); //get the file's contents

    $page_reference = cmtx_decode(cmtx_get_page_reference()); //get the reference of the current page
    $page_url = cmtx_decode(cmtx_get_page_url()); //get the URL of the current page
    $comment_url = cmtx_decode(cmtx_get_permalink($comment_id, cmtx_get_page_url())); //get the permalink of the comment

    $poster = cmtx_prepare_name_for_email($poster); //prepare name for email
    $comment = cmtx_prepare_comment_for_email($comment); //prepare comment for email

    //convert email variables with actual variables
    $body = str_ireplace('[page reference]', $page_reference, $body);
    $body = str_ireplace('[page url]', $page_url, $body);
    $body = str_ireplace('[comment url]', $comment_url, $body);
    $body = str_ireplace('[poster]', $poster, $body);
    $body = str_ireplace('[comment]', $comment, $body);
    $body = str_ireplace('[signature]', cmtx_setting('signature'), $body);

    cmtx_email($email, $poster, 'Subject text goes here', $body, cmtx_setting('subscriber_notification_basic_from_email'), cmtx_setting('subscriber_notification_basic_from_name'), cmtx_setting('subscriber_notification_basic_reply_to'));

}
//end of notify-user-new-comment function

Note this is just for when the comment does not need approval. For comments that need approval you'd also add the previous line below the cmtx_notify_admin_new_comment_approve function call in the /includes/app/processor.php file.

This also assumes the user entered their email address. If the email field is required then it won't be a problem.

Have you completed the interview?
Reply
#3

Steven,

Thank you kindly!
I have not had a chance to do it yet, but will today :-)
Sorry to take so long to reply. I have been crazy busy.

Thanks again, VERY, VERY, Much!!
Reply
#4
Wink 

Worked like a charm! Thank you kindly.
Goodness.... Took me FOREVER to get around to it. I truly appreciate your help and the wonderful program!

One last question in regards to this: Is it possible to send the emails in html format? I tried inserting an image into the email txt file the reviewer gets and it did not like that so much, haha.
Reply
#5

Which method are you using in Settings -> Email -> Setup?

Have you completed the interview?
Reply
#6

SMTP, but I can use any of them.
Reply
#7

Okay in /upload/includes/functions/page.php you can do the following:

Replace this:
PHP Code:
<?php 
$message
->setContentType('text/plain');

With this:
PHP Code:
<?php 
$message
->setContentType('text/html');

This will apply to all emails. Let me know if you only want it for the email above.

You'll also need to open your email text files and make sure it's all HTML e.g. each line is wrapped in a <p> tag and links use the <a> tag etc.

Have you completed the interview?
Reply
#8
Wink 

Worked GREAT! Thank you Steven!!
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by 2hands
28-Dec-2013, 07:15 PM
Last Post by Norbs
05-Jun-2011, 03:18 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)