#6750 closed enhancement (fixed)
Extending Messages notification should be improved
Reported by: | imath | Owned by: | imath |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 1.0 |
Component: | Messages | Keywords: | has-patch commit |
Cc: |
Description
If you try to add a new notification action (meaning !== 'new_message'), it's quite risky:
- First you get a notice error because in this case the $text var is not defined (which is not so serious)
- Most serious is you can't be sure to only filter your custom action because you need to filter
bp_messages_single_new_message_notification
which is not in theif ( 'new_message' === $action )
statement and which is not including the needed $action and $format variables.
Maybe we should improve this. See attached patch.
Attachments (2)
Change History (11)
This ticket was mentioned in Slack in #buddypress by imath. View the logs.
9 years ago
#6
@
9 years ago
- Keywords has-patch added; needs-patch removed
02.patch
handles the string format and also adds another edge case for the 'bp_messages_single_new_message_notification'
filter. If $format
is an array, there are seven parameters; if $format
is a string, there are six...:
https://buddypress.trac.wordpress.org/browser/tags/2.4.3/src/bp-messages/bp-messages-notifications.php#L212 :(
Not sure how people are using this filter at the moment!
#7
@
9 years ago
- Keywords commit added
02.patch looks good @r-a-y
We just need to make sure the @since
is bumped to 2.6.0 for the dynamic filter 'bp_messages_' . $action . '_notification'
Ugh, this was a pretty ugly one. Good catch, imath. Moving the
new_message
filter into theif ( 'new_message' === $action )
block, and introducing a new catch-all filter, both seem good to me.It's a pity that these filters were originally introduced as dynamic. We could greatly simplify the documentation, and greatly decrease the number of filters, if each notification function had a single filter:
bp_messages_format_notification
(or whatever), which would accept an$action
and$amount
parameter in addition to whatever params they normally accept. This is not a criticism of 6750.patch - it just copies what the rest of BP is doing. Just registering my sadness for the record :)