Automatically send Emails to users

Hello,

First of all I would like to say that I am not a developer and I do not have knowledge of php but if sb gives me step by step instructions I could follow them. I have created a buddypress website and I wonder if is there any easy way to make wordpress send emails to users if a specific condition exists. For example I would like to make wordpress send automatically emails to new users with some information about how my website works after they register and they are approved by admin or send an email each time a blog post is published etc. Is there an easy way to achieve that without using a plugin?

Thank you!!

  • Adam Czajczyk

    Hello Ioannis,

    I hope you're well today and thank you for your question!

    This can be achieved without installing any of existing plugins but what would you need to do would actually be.... writing a plugin. Since you say you're not a developer a "step-by-step" guide would mean in fact creating a custom plugin for you. Wouldn't it be better to simply use an existing solution?

    There are two nice plugins that could do just what you need:

    Automessage

    https://premium.wpmudev.org/project/automatic-follow-up-emails-for-new-users/

    It lets you set a single mail or a series of mails that are automatically send to the user after signup. It can for example contain a guide on what they'll find on your site and how to use it. It works pretty much like an autoresponder/follow-up system triggered by user signup and/or blog creation (on Multisite installs).

    Subscribe by Email

    https://premium.wpmudev.org/project/subscribe-by-email/

    It's a tool that automatically notifies users by e-mail of new posts. The downside - in relation to your case - is that those users would need to subscribe but you could either add them manually or it could even be possible to automatically add them as subscribers with some additional custom code I think (which I most likely could help you with).

    This plugin could also be used as an alternative to "Subscribe by Email" as it automatically notifes users of new posts without them needing to subscribe:

    https://wordpress.org/plugins/new-post-notification/

    Would that do the job for you?

    Best regards,
    Adam

  • Ioannis

    Hello Adam,

    Thank you for your suggestions but what I need is to make wordpress sent an email when an event happens or if a condition is matched by the system. That's why I try to avoid plugins. All the plugins that I have found can send an email only if a specific condition exists. Do you know if there is a plugin that will allow me set the conditions and if the conditions that I have set exist then an email is sent to users? For example I would like my buddypress members to receive an email everytime a message has been sent to them, or been informed about their new capabilities by email if their role has changed. I have found that wordpress already has a mail function https://developer.wordpress.org/reference/functions/wp_mail/ but I do not know how to use it. Do you think that what I am trying to achieve is possible?

    Thank you,
    Ioannis

  • Dimitris

    Hey there Ioannis,

    I hope you're well today! :slight_smile:

    Do you know if there is a plugin that will allow me set the conditions and if the conditions that I have set exist then an email is sent to users?

    Unfortunately, no. :slight_frown:
    Of course it is possible, but requires some custom coding. The best approach in my opinion would be to try to extend the new BP Email API. I really hope that you're running at least BP 2.5.0+ in order to have this capability. There's also an example in BP codex considering custom emails https://codex.buddypress.org/emails/custom-emails/ :wink:

    I would like my buddypress members to receive an email everytime a message has been sent to them

    This is already in place! :wink:

    and a member can turn it off, it he/she wants

    Hope that was some help, feel free to post back if more help is required. :slight_smile:

    Warm regards,
    Dimitris

  • Adam Czajczyk

    Hello Ioannis!

    Take a look here please: https://codex.buddypress.org/emails/custom-emails/#send-email

    This explains how you can use BP Custom Emails with pretty much every BP/WP "event" :slight_smile:

    Assuming that you already created your custom Emails (as explained a bit earlier on the same page) you can use the function to send any of these e-mails. The clue here is that to trigger it you simply hook it to any available hook.

    Based on this example you can send BP Custom Emails e.g.

    - when a post is published ("publish_post" action)
    - when a user updates WP profile ("personal_options_update" action)
    - when user logs in ("wp_login")

    and many more. If a filter/action (coming from WP core, BuddyPress or any other plugin) is available, you can hook to it to trigger "bp_send_email()" function which sends BP Custom Email that you created.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.