I'm trying to incorporate a 'Register interest' button into a website which when signing up will assign register the user to a user role and then when a custom field is updated in the property (CPT) it will automatically send out an email to the users who are assigned to a role letting them know a property is now available.

I have many properties in the custom post type which have a relationship to another custom post type 'court' so I've setup different user roles. If a user wants to be emailed about more than one courts properties then they will be assigned to multiple roles.

I thought by using the plugin, 'Better notifications for WordPress' with some of its premium add-ons would do the trick but this doesn't let me set a conditional rule on a custom field and only works if any property status has been published.

I've also tried setting up Mailchimp and collecting different emails on the site which would go into separate lists of the courts but I can't find anything which then allows me to setup a automatic email to go out these lists.

I did read about doing this manually through the wp_mail function following a tutorial on Smashing magazine, https://www.smashingmagazine.com/2015/05/building-wordpress-notification-system/ but reading the comments it talks the risks of being blacklisted.

Does anyone know of any solutions / plugins which could help me build this in?

  • 1
    This type of emails are called transactional emails. If you will sent a lot of emails it is better to use a service. As you mentioned there is the risk of being blacklist. Mailchimp offers Mandrill for this type of emails. Also Mailgun is a good choice. Although you have to implement what you described.
    – Laxmana
    Apr 5, 2017 at 8:25

1 Answer 1


This code will allow you to call a custom function when your meta key is updated.

add_action('updated_postmeta','my_meta_update', 10, 4);

function my_meta_update( $meta_id, $object_id, $meta_key, $meta_value ) {

    if($meta_key === 'my_meta_key') {
        // trigger email(s)
        // wp_mail( $to, $subject, $message, $headers, $attachments );

Like Shaun mentioned, you should always use an external email solution else your ip / domain will get blacklisted. You may even have email sending restrictions from your hosting provider.

  • Would using SMTP count as an external mail solution??
    – Shaun
    Apr 5, 2017 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.