Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


Add Discussion Subject in Email Body

edited March 2011 in Questions
This discussion is related to the EMailDiscussion addon.
How can I add the discussion subject in the email body?

Comments

  • I edited the last line of this section of the default.php file so it put the title of the post in the email body and removed the actual contents of the forum post itself as i did not want them there....



    class EMailSubscribe extends Gdn_Plugin {

    public function PostController_AfterDiscussionSave_Handler(&$Sender){
    $Session = Gdn::Session();
    $UserName = $Session->User->Name;
    $ActivityHeadline = $UserName . " has started a new discussion";

    $DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID;
    $DiscussionName = $Sender->EventArguments['Discussion']->Name;
    $CategoryID = $Sender->EventArguments['Discussion']->CategoryID;
    $Story = "Entitled..." . $Sender->EventArguments['Discussion']->Name;





    Now my emails basically look like...

    "MikeBerry has started a new discussion....

    Entitled.... How to fix something"
  • Yeah, that's just what I wanted, thank you!
  • Hi @bezzoh

    Could you possible supply the code for your whole default.php, or at least the bit that displays the text in the email body? Think its wrapped around $Message parameter. I'm trying to figure out what the parameter is to include the discussion title in the email body, but I'm struggling to work out your example above, as its quite different from my file... I've tried $DiscussionName and $Story so far.

    thanks,
  • I cant paste the whole default.php due to character limitations of this forum, however i have pasted from the top up to the change i mentioned above to achieve the goal I was after...




    <?php if (!defined('APPLICATION')) exit();

    /**
    * Changelog
    * 0.1.1
    * * fixed bug sending email to deleted users
    * 0.1.22
    * * fix typo
    * 0.1.30
    * * enforcing permissions - users can't subscribe to Categories that they don't have Vanilla.Discussions.View permission
    * 0.1.31
    * * reestablish the "Subscribe everyone to everything" and improve it with "everything they can view" via some SQL juggling.
    * 0.1.32
    * * fix bug where I left a die() in the code.
    * 0.1.33
    * * finally understood how categories and permissions work, despite the lack of documentation in the code.
    */

    $PluginInfo['EMailSubscribe'] = array(
    'Description' => 'Enables users to subscribe to receive e-mails when new posts in different Categories are posted',
    'Version' => '0.1.33',
    'RequiredApplications' => NULL,
    'RequiredTheme' => FALSE,
    'RequiredPlugins' => FALSE,
    'HasLocale' => FALSE,
    'Author' => 'Catalin David',
    'AuthorEmail' => 'c.david@jacobs-university.de'
    );


    class EMailSubscribe extends Gdn_Plugin {

    public function PostController_AfterDiscussionSave_Handler(&$Sender){
    $Session = Gdn::Session();
    $UserName = $Session->User->Name;
    $ActivityHeadline = $UserName . " has started a new discussion";

    $DiscussionID = $Sender->EventArguments['Discussion']->DiscussionID;
    $DiscussionName = $Sender->EventArguments['Discussion']->Name;
    $CategoryID = $Sender->EventArguments['Discussion']->CategoryID;
    $Story = "Entitled..." . $Sender->EventArguments['Discussion']->Name;

  • I think your talking about the EmailSubscribe plugin, but this discussion originally started asking about the EmailDiscussion plugin which allows an admin to email a new discussion to all users in the forum. Hence why i was a bit confused looking at your code last week... :)
  • As i was really keen to use this feature I've looked up some php code to do it.
    After line 53 ish of the default.php you shoudl have something similar to:
    $Subject = "blah blah blah";
    Add underneath:
    $PostTitle = $_REQUEST['Discussion/Name'];
    $PostContent = $_REQUEST['Discussion/Body'];

    Within the email section below that (contained within the $Message container), you can then reference $PostTitle and $PostContent to make the discussion title and body copy appear as appropriate.
    Works well for me anyway... :)
    DavidShine
  • Thanks Bezzoh, very much this was the only solution to stopping PHP code being sent in the emails when WYSIWYG plugins are installed. Save me a sleepless night.

    DavidShine
  • Please help I'm at total loss where to find this problem: where do i find the code???
    No 1::
    admin started a discussion. email testing --- Follow the link below to check it out: http://www.korat-expatsforum.services-thai.com/discussion/53/email-testing Have a great day!
    I recive this without the link highlighted on one Forum then on the other forum I receive the one below which is correct >

    No 2:: admin has started a new discussion

    Entitled...Case of Central World arson to be ruled in late March


    Follow the link below to check it out: http://www.surin-expatsforum.services-thai.com/discussion/6/case-of-central-world-arson-to-be-ruled-in-late-march

    Have a great day!

    DavidShine
  • Please help I'm at total loss where to find this problem: where do i find the code???
    This was solved this morning: Thanks to help from Vrijvlinder.

    DavidShine
  • I think this is the code thats tell what to send out in EMailDiscussion/default.php:

    <

    p>A new message has been posted by ' . $Name . '. It can be accessed at Link If i wanted to ad the "Discussion Title" because this is what would make members click the link. How would add "Discussion Title" ? I want to use this not just as a message email but to generate visits. I have tried many ways but just keep coming up with line errors. I only been learning PHP/ HTML for about 4 weeks so need some help. Thanks, Denis

    DavidShine
Sign In or Register to comment.