BuddyDev

Search

Admin notifications

  • Member
    deleted on #24070

    I have a community that brings together teachers and students to discuss the courses sold on the site and would like to have all of the teacher’s (admin) activities published in the feed sent to users participating in the group whenever they post something.

    I researched some plugins to see if there was anything ready to do this but I did not find it.
    I currently use your BuddyPress Group Activities Notifier plugin but it generates notifications from all members of the group, would it be possible to add some custom code to it so that only admin activities are sent?

    Any help will be welcome.

    Thank you!

  • Keymaster
    (BuddyDev Team)
    Posts: 24653
    Brajesh Singh on #24100

    Hi,
    Sure you can use the filter ‘bp_local_group_notifier_skip_notification’

    Based on current user, return true for everyone except Teachers.

    It will skip the recording for them.

    Please see
    https://github.com/sbrajesh/bp-group-activities-notifier/blob/master/bp-group-activities-notifier.php#L116

    Regards
    Brajesh

  • Member
    deleted on #24350

    Thanks for answering.

    I tried two different codes that I tried to modify, see:

    
    
    function function1( $stop_notification ) {
    
    	if ( bp_has_member_type( bp_displayed_user_id(), 'student' ) ) {
    		$stop_notification = true;
    	}
    
    	return $stop_notification;
    }
    add_filter( 'bp_local_group_notifier_skip_notification', 'function1' );
    
    

    With this function I expected users with member type “students” not to generate notifications when posting something but this is not working.

    
    
    function function2( $stop_notification ) {
    	
    	$member_type = bp_get_member_type( bp_displayed_user_id() );
    	if ( 'student' !== $member_type ) {
    		$stop_notification = true;
    	}
    
    	return $stop_notification;
    }
    add_filter( 'bp_local_group_notifier_skip_notification', 'function2' );
    
    

    This second also did not work. And she removed the notification for any users, even teachers were not generating notifications. I tried to change the !== to === but it didn’t work either.

    • This reply was modified 5 years, 4 months ago by deleted.
  • Keymaster
    (BuddyDev Team)
    Posts: 24653
    Brajesh Singh on #24393

    Hi,
    Your problem is the use of

    
    bp_displayed_user_id()
    

    It is only valid when you are on a user’s profile. Please give the following code a try

    
    function bpcustom_disable_group_notifications_for_student_posts( $stop_notification ) {
    
    	if ( bp_has_member_type( get_current_user_id(), 'student' ) ) {
    		$stop_notification = true;
    	}
    
    	return $stop_notification;
    }
    
    add_filter( 'bp_local_group_notifier_skip_notification', 'bpcustom_disable_group_notifications_for_student_posts' );
    
    

    It is modified version of your code and should work.

    Please let me know if it does or not?

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved