BuddyDev

BuddyPress Group Activities Notifier

BuddyPress Group Activities Notifier plugin notifies group members of any new activities in his/her group on BuddyPress based Social Networks.

It is based on simple idea to add a local notification for user(Like in other social networks) when any activity happens in his/her group.

Here is what it does currently.

Features:-

  • Notifies members if someone posts an update in the group
  • Notifies members if a user joins the group
  • Notifies members if someone posts a new topic
  • Notifies members on new reply in the forum
  • Should work for any other plugin which adds activity in the group

Screenshots:-

Currently, in the initial release, it only locally notifies the users(Adds these to users notification list on the network).

Notify by email:-

This  plugin does not support notification by email out of the box. The email notifications are resource intensive and based on the number of members of group, may cause timeouts. If you still believe that you want the email notification, you can put the following code in your bp-custom.php

function buddydev_mail_on_new_group_activity( $user_ids, $args ) {

	if ( empty($user_ids ) ) {
		return ;
	}
	//do a bulk query
	$users = get_users( array( 'include' => $user_ids ) );

	$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 = <<<'MAINCONTENT'
	Hi %1$s,
	%2$s posted...
	
	%3$s

	Link: %4$s
MAINCONTENT;

	foreach ( $users as $user ) {
		$message = sprintf( $message, $user->displayname, $loggedin_user_display_name, $activity_content, $activity_permalink );
		wp_mail( $user->user_email, $subject, $message );
	}
}
add_action( 'bp_group_activities_notify_members', 'buddydev_mail_on_new_group_activity', 10, 2 );

It is recommended to use an email queuing plugin if you are using the above code.  you may use any of the below:-

 

Future Plans:-

These or other features may come depending on your suggestions on the blog post. Go ahead and let us know your suggestions here.

  • Should we allow users to opt out of the notifications? If yes, what should we do by default, keep them subscribed and allow to unsubscribe ?
  • Should we send emails on new group activities?
  • Is there anything else you want to do ?
Github Repo:

It is Free, enjoy 🙂

Release History

  • Version: 1.0.7

    Wednesday, 28 February, 2024
    • Tested With: BuddyPress 12.2.0
    • Compatible With: BuddyPress 8.0+

    Improves the detection for group activity id.

  • Version: 1.0.6

    Tuesday, 29 June, 2021
    • Tested With: BuddyPress 8.0.0
    • Compatible With: BuddyPress 6.0+

    Fix user notifications persisting even after activity gets deleted

  • Version: 1.0.5

    Monday, 08 April, 2019
    • Tested With: BuddyPress 4.2
    • Compatible With: BuddyPress 2.5+

    Cleanup and added filter for notification url.

  • Version: 1.0.4

    Friday, 09 September, 2016
    • Tested With: BuddyPress 2.6.2
    • Compatible With: BuddyPress 2.4+

    Huge improvement in queries. Just 1 query to add all notifications in most of the case. If members larger than 200, query is chunked in the size of 200 members. It saves a lot of resource.

  • Version: 1.0.3

    Thursday, 01 September, 2016
    • Tested With: BuddyPress 2.6.2
    • Compatible With: BuddyPress 2.4+

    refactored and updated

  • Version: 1.0.2

    Tuesday, 05 April, 2016
    • Tested With: BuddyPress 2.5.2
    • Compatible With: BuddyPress 2.2+

    Updated code and added filter to allow skipping some types of notifications using filter 'bp_local_group_notifier_skip_notification'

  • Version: 1.0.1

    Sunday, 12 July, 2015
    • Tested With: BuddyPress 2.3.2.1
    • Compatible With: BuddyPress 2.2+

    Updated to work with BuddyPress 2.2+

  • Version: 1.0

    Saturday, 02 March, 2013
    • Tested With: BuddyPress 1.7+/BuddyPress 1.8
    • Compatible With: BuddyPress 1.7+/BuddyPress1.8

    Initial release