Programming WordPress to Send an Email on Registration Form Submit?

(Moderator's note: The original title was: "submit button in wordpress.")I'd like to create a regist

(Moderator's note: The original title was: "submit button in wordpress.")

I'd like to create a registration form to send an email.

I've tried Contact Form 7 but I would like to use my own HTML <form>. I can do the entire coding but I just want to know the code for the "submit" button so that the registrations goes directly to my admin email ID as I don't think the normal HTML code for the submit button will work.

Can anyone help me out in this?

(Moderator's note: The original title was: "submit button in wordpress.")

I'd like to create a registration form to send an email.

I've tried Contact Form 7 but I would like to use my own HTML <form>. I can do the entire coding but I just want to know the code for the "submit" button so that the registrations goes directly to my admin email ID as I don't think the normal HTML code for the submit button will work.

Can anyone help me out in this?

Share Improve this question edited Dec 3, 2010 at 6:53 MikeSchinkel 37.6k14 gold badges117 silver badges132 bronze badges asked Dec 3, 2010 at 4:58 Niraj ChauhanNiraj Chauhan 8503 gold badges19 silver badges43 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

While you might be able to do something on the client with jQuery I think your best bet would be to use the Post/Redirect/Get Pattern and submit your registration form via a <form method='post'> action.

The code after the screenshot below is a "Page Template" for a "Page" illustrates how to achieve what you've asked for with WordPress. Copy the code to your theme directory as page-contact-form.php (or some other name you like better) and then create a page that has template set to "Contact Form" as you see in the screenshot (note I kept the page template as simple as possible to illustrate the technique; you'll typically have a lot more code in your real live page templates):


(source: mikeschinkel)

<?php
/*
  Template Name: Contact Form
*/
define('ADMIN_USER','mikeschinkel');
if (count($_POST)) {
  $admin_user = get_userdatabylogin(ADMIN_USER);
  $registered_email = $_POST['email'];
  wp_mail($admin_user->user_email,
    'New Site Registration',
    "New Site Registration:\n\tEmail: {$registered_email}.");
}
?>
<?php get_header(); ?>
<?php if (count($_POST)): ?>
    <p>Hey <?php echo $_POST['email']; ?>, thanks for registering!</p>
<?php else: ?>
  <form method="post">
    Email: <input type="text" name="email" />
    <input type="submit" value="Register" />
  </form>
<?php endif; ?>
<?php get_footer(); ?>

After you've created your page with the above page template it might look something like this on your external site:


(source: mikeschinkel)

And this might be what it looks like after a visitor registers:


(source: mikeschinkel)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745613982a4636118.html

相关推荐

  • Programming WordPress to Send an Email on Registration Form Submit?

    (Moderator's note: The original title was: "submit button in wordpress.")I'd like to create a regist

    10小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信