buddypress-group-email-subscription
buddypress-group-email-subscription copied to clipboard
Enhancement: Safeguard the ass_block_group_activity_types
Hello,
Minor enhancement request, nothing really broken here more requesting to save others from their own stupidity as that's what I just ran into on my own ;)
Within the function 'ass_group_notification_activity' of the file 'bp-activity-subscription-functions.php' there's a check for false from the filter 'ass_block_group_activity_types';
// if you want to conditionally block certain activity types from appearing,
// use the filter below
if ( false === apply_filters( 'ass_block_group_activity_types', true, $activity->type, $activity ) )
return;
In my case I was setting up a custom filter within a custom plugin and had;
add_filter( 'ass_block_group_activity_types', 'wplms_block_custom_group_activity_types', 10, 3 );
Which caused an error "call_user_func_array() expects parameter 1 to be a valid callback" because I didn't properly reference the function within a $this array.
Anyway because of this the 'ass_default_block_group_activity_types' filter within the plugin was basically ignored as my filter was causing the value to be NULL which isn't false so I was getting emails sent for all joined_group, etc. activity. In short my minor mistake caused 5000+ undesired emails to send.
To avoid this and safeguard against any other plugins or users who incorrectly set-up the filter, either by misspelling their function or not properly class scoping it, was hoping the logic be flipped so that a NULL response is also considered false;
// if you want to conditionally block certain activity types from appearing,
// use the filter below
if ( true !== apply_filters( 'ass_block_group_activity_types', true, $activity->type, $activity ) )
return;
This should not only help my case but if someone returned anything but true would be considered false.
Thanks