When a member send a message to another member, the recipient receive a message in buddypress and also an email.
I want to change that because if you receive many messages, you have too much mail in your mailbox even if you are logged in : I want to receive mail only if I am not logged in buddybress.
I have find where adding the code but I don’t know how to hooks (add_action or add_filter)
The file is : wp-content/plugins/buddypress/bp-messages/bp-messages-notifications.php
and the modification is at the end of file, just adding the if test before sending email :
if (!is_user_online($recipient->user_id)) {
wp_mail( $email_to, $email_subject, $email_content );
}
How I can do this without change the core file of buddypress ?
One thing you can do is to filter
$email_to
and return empty string if the recipient is logged in. This waywp_mail()
will fail to send the message and return false. Add the following to themefunctions.php
or tobp-custom.php
file:EDIT: A possible solution for your case with the plugin you use is to get all the users who have that e-mail and check if any is online by passing that list to
bp_has_members()
function: