Hi,
I have a plugin which is unfortunately very buggy and hardly maintained by the plugin author. This plugin throws a notification when a user writes a review for another user.
The problem is, that these notifications not get deleted after a user – where the notification points to – is deleted by admin or delets himself. So other users still have notifications in their user settings or in the header and but when the click on that link a PHP error message appears cause that user doesn’t exists anymore.So how can I fix this? I had a look at the database and saw there were two tables regarding the notifications system, the bp_notifications and the bp_notifications_meta table.
So my question is: Is it enough just to hook into the WP deleted_user action and delete all notifications with the same user id in the bp_notifications table?
But does this not have influence on any other funtions of bp? And what is the bp_notifications_meta table for? Do I have to delete anything there as well?
Hi,
Thank you for the question.I am sorry to hear your experience abut the plugin.
There is not way well defined way to know which notifications belong to the deleted user. Most of the time the
secondary_item_id
is used for the original item id(could be the user).I will suggest searching for
bp_notifications_add_notification
in the reviews plugin to find out how they are dealing with the reviewer user id.(The user_id field in notification is for receiver user id).Notification meta table allows adding extra data to notifications. BuddyPress does not add any extra data. If you are using a plugin like BP Better Message, they might add some additional data in the meta table.
Regards
BrajeshMeanwhile the plugin author wrote and said, its a issue of buddypress and not his plugin. Strange.
Anyway, I checked the notification table once again. The review plugin stores its information with the component_action column and the user id as the secondary_it_item column.So I hope if I write some routine which deletes all entries in this table with the related user (after_user-delete hook) I am fine and don’t destroy other things.
What’s your opinion about that? Does any plugin has to take care of deleting data in these tables when a user gets deleted or is it a wordpress thing?
Hi Josh,
Thank you for the reply.It is definitely a plugin bug. Not cleaning notifications on user delete is related to how that plugin uses notification and not related to BuddyPress. BuddyPress has no idea what is in secondary_item_id.
You will need to use
delete_user
ordeleted_user
hook.Regards
Brajesh
You must be logged in to reply to this topic.