WORDPRESS: Hacking Comment Form to act like Tell a Friend

I have a client that is using WP for a CMS. He wants un-registered users to be able to submit content. It’s a form that has the following fields:

Your name

Read More

Your email

Friend’s name

Friend’s email

Message

Submit

Then the message would be posted on the site (as a comment) and that message/comment would then be emailed to the Friend’s email address. So the email would look like so:

Hey Friend,

Your name said something about you. Isn’t that cool?

Blah blah blah blah blah and etc.

How difficult would it be to accomplish this and if it is possible, can someone please point me in the proper direction? I figure there are fields I need to add to the comment form and that I can figure out on my own. It’s the whole sending the actual comment in an email to that email address that’s causing issues for me.

TIA!

Related posts

Leave a Reply

1 comment

  1. Create a new comments template with your extra fields. See more about how to do this at the Codex.

    Add a hook for the ‘comment_post’ action. It’s defined around line 997 of comment.php. At this point, the comment will have already been inserted into the database. You can send your email here using the wp_mail function defined around line 254 of pluggable.php.

    If you want to do some preprocessing on the comment text, ‘pre_comment_on_post’ might be your best bet. It’s defined around line 34 of wp-comments-post.php.