Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

creating a wp_mail function to send email to subscribers

l have created a a from on my site that registers users as subscriber and wanted to know if there was a way of using wp_mail to send a notification email to these subscribers. l have tried a few working sample code snippets which came up on my google search but none seem to be passing. But first of all wanted to know does should this new_user_notification function only be called in a plugin or can be placed in a function.php like every other core wordpress function that we can override? any ideas or experience with using this and code share would be great guys. Thanks. Zac Gordon

Seph Cordovano
Seph Cordovano
17,400 Points

I've never actually emailed out from wp_mail, I always use a form builder (Form Craft) and update subscribers that way after (very easily) integrating Mail Chimp. Another option, depending on volume of site, is to use Form Craft to send them an email when they sign up and you one with their information (email to you and email to them can be different) and then you personally add it to you your subscribers' email list. Then you don't pay a monthly subscription cost to Mail Chimp and can just pick up a free, or premium, HTML markup email theme and create a draft that you just copy and edit each time you mail out. Not too much more work if the Volume is low and you can always scale this later, especially because you'll already have all the previously signed up emails.

Hopefully this quick fix helps!

1 Answer

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Technically speaking the code you're added should be done as a plugin and not as part of the theme. That said, the hooks will still work in your functions.php file.

WP Mail is pretty straight forward (http://codex.wordpress.org/Function_Reference/wp_mail) unless there is something server related. Confirm that you can send a normal PHP email first just in case.

Its got postmark tied into it all as a plugin. l might ask you some questions while you are here. Can you advice me on how to make your wishlist appear on your my account page please. l am using woocommerce and have customized it a bit to suit my needs. l have got a custom my account page working and managed to get the wishlist displaying but its not displaying any products when l add one to the wishlist.

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Hi! Let's keep it to one topic per forum post, but feel free to post up a new question!

Did you get your previous problem solved?

l created a new post here link. llam working on that now suppose i need more help with woocommerce instead. Thanks mate .