WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] Writing a plugin that notify my friends of new post that mentions(@) them

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

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Writing a plugin that notify my friends of new post that mentions(@) them’ is closed to new replies.