Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
coding-topic
Newbie editing: sp_email_notifications
Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 19, 2013 - 8:33 am

Okay - trying the mods on the email.  When you suggest taking the template language for sending an email from "core", what file are you referring to.  Thanks.
==> I think I found the file (sp-post-support) - should I just copy the $msg section and work from that?

Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 19, 2013 - 10:24 am

Here's the latest of where I stand:

1) Created a new theme

2) Put this in the functions.php, which works(!), except as noted below:

add_filter('sph_admin_email', 'my_admin_email', 10, 2);
function my_admin_email($content, $newpost) {

        $post_content = spdb_table(SFPOSTS, 'post_id='.$newpost['postid'], 'post_content');
        $post_content = sp_filter_email_content($post_content);

        $content  = sp_text('TEST forum post on your site').': '.get_option('blogname'). $eol . $eol;
        $content .= sp_text('From') . ': '.$tab . $newpost['postername'].' ['.$newpost['posteremail'].']'.', '.sp_text('Poster IP').': '.$newpost['posterip']. $eol . $eol;
        $content .= sp_text('Group'). ':'.$tab . sp_filter_title_display($newpost['groupname']) . $eol;
        $content .= sp_text('Forum'). ':'.$tab . sp_filter_title_display($newpost['forumname']) . $eol;
        $content .= sp_text('Topic'). ':'.$tab . sp_filter_title_display($newpost['topicname']) . $eol;
        $content .= urldecode($newpost['url']) . $eol;
        $content .= sp_text('Post') . ':'.$eol . $post_content . $eol.$eol;

    return $content;
}

3) The above works - however: html coding does not come through (not too worried about this yet).  More important, the email that comes through looks like the following - note: line breaks within the post are coming through, but the post information is not coming through with line breaks (I guess the .eol is what that's for, but it's not helping).

TEST forum post on your site: Village Presbyterian ChurchFrom: Admin [admin@villagepca.org], Poster IP: 174.255.57.252Group:Church LifeForum:Prayer RequestsTopic:A test post for John's sakehttp://http://villagepca.mailgun.org/c/ZD0wOTA5YSZoPWUxYTY1ZDRkMzUyZWQyOGNhODAzNjk4YjEwYTI5Njg3Jm09engyJmw9d3d3LnZpbGxhZ2VwY2Eub3JnJTJGY2h1cmNoJTJGZm9ydW0lMkZwcmF5ZXItcmVxdWVzdHMlMkZhLXRlc3QtcG9zdC1mb3Itam9obnMtc2FrZSUyRiUyM3AxOFBvc3QlM0FBJnI9cnhjb3N0YSU0MGdtYWlsLmNvbSZ0PVdvcmRQcmVzcyZ0PXZpbGxhZ2VwY2Eub3Jn test 1

A test 2

A test 3

 

 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 19, 2013 - 12:30 pm

the code you copied did not include the setting of variable $eol...  grab that from the start of the core routine and add it to your routine...

and our emails are not set for html content...  caused too many problems with folks who were not allowing html emails - yes, significant number of folks still do that...

Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 19, 2013 - 4:02 pm

Okay - thanks.

How can I change the subject line of the email (or from, etc.)

Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 19, 2013 - 4:14 pm

P.S. The $eol fix was right on.  However, now the email I get has two parts to it - the first part looks like the default template for the email, and the second part looks like the format I programmed.  How do I turn off the first part?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
May 19, 2013 - 5:10 pm

The 'from' is set on forum admin > options >email panel.

I explained to you about the use of html email in post 6 of this thread.

If you now have both showing up then I assume you are concatenating your new content onto the original content being passed to your function. You might want to destroy the content being passed in to your function with a $content = ''; as the first statement.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 19, 2013 - 5:25 pm

Thanks - sorry I missed the link on html.  Where is the wp_mail call happening for Simple:Press?  Is there any easy way to change the Subject line? 

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
May 19, 2013 - 8:35 pm

add a new filter on the subject...  use filter 'sph_email_subject'...

Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 21, 2013 - 5:20 pm

Thanks - shockingly, I think I figured out how to change the 'reply to' by using sph_email_replyto - I presume that's right?  So I changed the reply-to to be the poster - however, that means if the admin posts, he doesn't get copied on the post (because I think his email app will see that he is the "reply-to" and thus thinks he's sending his email and it doesn't go into the in-box).

So how can I add a "bcc" to an email?

 

Avatar
Roy Costa
Member
sp_UserOfflineSmall Offline
May 21, 2013 - 5:30 pm

This is what I have - in the sp_functions of my theme

add_filter('sph_email_replyto', 'my_admin_replyto', 10, 2);
function my_admin_replyto($replyto, $newpost) {

        $replyto = $newpost['posteremail'];

    return $replyto;
}

add_filter('sph_email_subject', 'roy_email_subject', 10, 2);
function roy_email_subject($subject, $newpost) {

        $subject = $newpost['email_prefix'].sp_filter_title_display($newpost['topicname']);

    return $subject;
}

I thought it was working but not anymore - what am I doing wrong?

 

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626