Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to Disable ALL BuddyPress Emails


  • Christian Freeman (codelion)
    Participant

    @takinglife2themax

    Hi guys,

    I’m building a new BuddyPress plugin, and I want to use my own internal email system instead of the BP_Email system. My question is, is there a function, filter, or something else that I can use to disable ALL BuddyPress Emails? (This includes Activation, Notifications, etc.)

    Also, are there any action hooks that I can use to send my own emails instead? For example, after a user gets a new Friend Request, pass in the required token data and send my own email.

    Many thanks, and keep up the excellent work guys!

Viewing 9 replies - 1 through 9 (of 9 total)

  • shanebp
    Moderator

    @shanebp

    Go here and scroll to the bottom: https://codex.buddypress.org/emails/


    Christian Freeman (codelion)
    Participant

    @takinglife2themax

    Thanks for the super quick response @shanebp!

    I did take a look at this filter, but in reviewing the BP_Email class, it would appear that this only disables the BP PHP Mailer templating system, but still sends the email using WP Mail.

    I really want to prevent it from sending any BP Emails at all, whether through WP Mail, or the BP_Email system.

    I also noticed the “bp_send_email” action hook, which looks like it could be used to collect all of the token data from the email before it is sent:

    https://github.com/buddypress/BuddyPress/blob/6f6bbc1ccf78a1c91e7b0bf33de704807570002b/src/bp-core/bp-core-functions.php#L3140

    In theory, I could use this to send my own email using the Email Type and Token data. Is there anywhere in the BP source code that will show me how the associative array for the Token data is formatted? And is there anywhere that I can see a list of the supported Email Types?

    Any help with this would be much appreciated!


    Christian Freeman (codelion)
    Participant

    @takinglife2themax

    Also, just to give a bit more info on what I’m trying to do.

    I want to hook in and send my own email using WP Mail and my own Templating system, and ideally, I’d like to stop BP_Email from sending another duplicate email right after. Whether that’s via the BP PHP Mailer or WP Mail.


    shanebp
    Moderator

    @shanebp

    You should be able to use bp_send_email to adjust $email so that it fails validation on the next line.
    And your function could send a custom email at the same time.
    It will get messy – always easiest to use the provided functions.

    afaik – the email classes are in bp-core > classes.
    You’ll need to review them to get the info you want.
    There are some articles in the documentation that may provide clues:
    codex.buddypress.org/?s=email


    Christian Freeman (codelion)
    Participant

    @takinglife2themax

    Thanks!

    How would I go about making the $email object fail the validation step?

    I understand that bp_send_email is an action hook, but wouldn’t I need this to be a filter to alter the $email object?


    shanebp
    Moderator

    @shanebp

    >How would I go about making the $email object fail the validation step?

    Check the validation routine and change the $email object so that it will fail.

    >I understand that bp_send_email is an action hook, but wouldn’t I need this to be a filter to alter the $email object?

    The object is passed by reference, note the &.
    http://php.net/manual/en/language.oop5.references.php


    Christian Freeman (codelion)
    Participant

    @takinglife2themax

    Nice, I didn’t know that the object could be passed in that way. Very cool indeed.

    Also, I checked the validatemethod, and I found the bp_email_validate filter that I can use to force it to fail the validation as well:

    https://github.com/buddypress/BuddyPress/blob/fe47890c1ab7e2cb24c005f1c35fb9c6c8c8ab7c/src/bp-core/classes/class-bp-email.php#L961

    From what I understand, I only need to swap the current value with my own WP Error to force it to fail validation and stop sending the BP Email, right? I think this could be a bit smoother for toggling BP Emails on and off via my plugin settings.

    Well, not I just need to track down all of those email tokens and we’re in business!

    Many thanks for all of your help @shanebp! It’s much appreciated.

    My goal with this plugin is to eliminate the need for BP users to have to purchase a theme coded for BuddyPress. And beyond that, it will add a ton of functionality designed to make starting and running a BP community a breeze.

    I should have my new BP plugin onto the WP Repo within the next 30 days or so. What do you think is the best way to spread the word to BP users?


    shanebp
    Moderator

    @shanebp

    > What do you think is the best way to spread the word to BP users?

    Post in these forums. If you can setup a demo site, that would be great.


    Christian Freeman (codelion)
    Participant

    @takinglife2themax

    I definitely plan to have a demo site in place, I’ve already started building it.

    Is there a particular place I should post on this forum to let people know about it and get their feedback?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar