We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Get comment text on delete | Forum

Sean Dec 8 '16
I'm developing a plugin that will notify a user when a comment is deleted by an admin.

I can see that there is an event for when a comment is deleted, but this is called after the comment has been removed from the database, and I can see no way of getting the text before it is removed.

This is the event that runs, but as I say, the comment is deleted before this is called so I have no way of grabbing the text first:

$event = new OW_Event('base_delete_comment', array(
            'entityType' => $commentEntity->getEntityType(),
            'entityId' => $commentEntity->getEntityId(),
            'userId' => $comment->getUserId(),
            'commentId' => $comment->getId()

Can anyone help?

dave Leader
dave Dec 8 '16
Hi, usually there is a  feed.onBefore?????Delete  or  something like that which you can use for your hook, but i have not found one for comment yet.  I will keep you posted. 

I looked thru all the event handler files i could find and nothing to hook into on comment delete that i found.   Closest i found was  feed_after_comment_add, but no delete version.

Youll probably just have to keep searching via agent ransack for the keyword to find it, if it exists. 

The Forum post is edited by dave Dec 8 '16
Sean Dec 8 '16
Yeah I found the feed delete one, but it won't cover things like comments deleted in groups, and the inbuilt comments delete hook doesn't cut it as it runs after the comment has been removed and there is no way to grab the comment text. 

I want to send a notification to the user like "your comment" blah blah" has been deleted. Please review the site guidelines"

But the way things stand you can't grab the comment text. 
dave Leader
dave Dec 8 '16
Yeah i agree they need a few more hooks here and there. Thats probably why noone has done this before.  Im trying to think of a work around for you but im not coming up with anything yet.. 

To bad that the delete event is not also associated with another event we might get lucky and go off the other event, wishfull thinking i guess.  

The Forum post is edited by dave Dec 8 '16
Senior Developer Leader
Senior Developer Dec 10 '16

Hi Sean!

You can do it just grabbing the event before the other event takes action.

The newsfeed delete event has a priority of 1000, so your code need to run before the newsfeed event.

I haven't tested but I think that this is the solution:

In your event handler file, just add this line


OW::getEventManager()->bind('base_delete_comment', array($this, 'deleteComment'), $priority);

Please let us know if this works.

Thank you!

The Forum post is edited by Senior Developer Dec 10 '16
dave Leader
dave Dec 10 '16
WOW SD amazing solution, your much better than i am for sure buddy. :)
Sean Dec 11 '16
Thanks senior. I'll give it a go tomorrow and report back. 
natasha singh

I love reading this post, big fan. Keep up the good work and please let me know when can you publish more articles or where can I read more on this topic.

Bangalore Escorts|| Bangalore Escorts Service|| Escorts Service in Bangalore|| Escorts in Bangalore|| Call Girl in Bangalore|| Bangalore Call Girls|| High Profile Escorts in Bangalore|| Bangalore Model Escorts|| Independent Escorts in Bangalore|| VIP Escorts Service in Bangalore

siya koli
siya koli Feb 18
You must have known that some agency who run adult website has no or little knowledge about the privacy policy of Escort. Zirakpur Call Girl Cash Payment It’s very important for you to know the best way to choose and select the best girls Escort.