[resolved] Writing a plugin that notify my friends of new post that mentions(@) them (4 posts)

  1. Architect
    Posted 3 years ago #

    For example, I write a new post with content "Today I'm happy, because I finally met the girl that @David told me about bla blah..." Once the post is published, there should be an email notification sent to David about this post that mentions him. Is there already such plugin? If not please help me with my implementation. Thanks a million time! :)

    The script needs to first parse the content of this new post. Find names after '@', then go to database to match commenter's name in order to get his/her email address (Assuming the person that I @ must have comment on my blog before)

    The basic send email part is below.

    function email_friend() {

    $postTitle = get_the_title($id);
    $post_permalink = get_permalink( $id );
    $to = 'David@email.com';
    $subject = 'Arch!tect mentioned you in his new post《'.$postTitle .'》';
    $from = "noreplay@myWebsite.com";
    $headers = "From:" . $from;

    $message = "Arch!tect mentioned you in his new post《".$postTitle .
    "》 check it out?\n\n" ."Post link:".$post_permalink
    ."\n\n\nPlease don't reply this email:P\r\n";

    mail($to, $subject, $message, $headers);

    add_action ( 'publish post', 'email_friend' );

    Done with simple part!

    Now please help me with the hard part...parsing name in post and fetching email address in database.

  2. Tara
    Volunteer Moderator
    Posted 3 years ago #

  3. Architect
    Posted 3 years ago #

    thanks it's solved there!

  4. Architect
    Posted 3 years ago #

    oh forgot to tick resolved

Topic Closed

This topic has been closed to new replies.

About this Topic