Created
February 29, 2024 10:28
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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