Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created February 29, 2024 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/42025f1a9a532b7cea4c7494180177dd to your computer and use it in GitHub Desktop.
Save KaineLabs/42025f1a9a532b7cea4c7494180177dd to your computer and use it in GitHub Desktop.
BuddyPress - Youzify Send email notifications to All users if there's a new posts
<?php
/**
* Youzify - BuddyPress Notify Users on New Activities.
*/
add_action( 'youzify_after_adding_wall_post', 'yzc_notify_users_on_activities', 999 );
function yzc_notify_users_on_activities( $activity_id ) {
$subject = "New activity posted!";
$message = 'New activity has been posted, please visit ' . bp_activity_get_permalink( $activity_id );
// Get all users.
$authors = get_users( array( 'fields' => 'user_email' ) );
// Update Fields.
foreach ( $authors as $user_email ) {
wp_mail( $user_email, $subject, $message );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment