Hello,
Please use the following code. It will send email notification to all group members on new activity update,
function buddydev_mail_on_new_group_activity( $user_ids, $args ) { if ( empty( $user_ids ) ) { return; } $user_emails = array_map( function ( $user_id ) { $user = get_user_by( 'id', $user_id ); if ( ! $user ) { return; } return $user->user_email; }, $user_ids ); $user_emails = array_filter( $user_emails ); if ( ! $user_emails ) { return; } $group = new BP_Groups_Group( $args['group_id'] ); $loggedin_user_display_name = bp_get_loggedin_user_fullname(); $activity = new BP_Activity_Activity( $args['activity_id'] ); $activity_content = $activity->content; $activity_permalink = bp_activity_get_permalink( $activity->id, $activity ); $subject = sprintf( '%1$s posted to %2$s', $loggedin_user_display_name, $group->name ); $message = <<<MAIN Hi, {$loggedin_user_display_name} posted... {$activity_content} Link: {$activity_permalink} MAIN; wp_mail( $user_emails, $subject, $message ); } add_action( 'bp_group_activities_notify_members', 'buddydev_mail_on_new_group_activity', 10, 2 );
Please do let me know if it works or not.
Regards
Ravi
You must be logged in to reply to this topic.
This topic is: not resolved