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
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
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


$priority=999; 

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
Sean Dec 11 '16
Thanks senior. I'll give it a go tomorrow and report back. 
natasha singh
natasha singh Jan 9 '23

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 '23
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.
Timothy Ferriss
Timothy Ferriss Nov 20 '23
The challenge you're facing is that the comment deletion event occurs after the comment has been removed from the database, making it impossible to retrieve the comment's text directly from the event. To overcome this NBA Grid limitation, you'll need to intercept the comment deletion request before it reaches the database and extract the comment text before it's deleted.
The Forum post is edited by Timothy Ferriss Nov 20 '23
REHMAN
REHMAN Jun 11
informatii interesante si utile postate pe blogul dumneavoastra. dar ca si o paranteza , ce parere aveti de cazarea in regim hotelier ?. a course in miracles
REHMAN
REHMAN Jun 11
informatii interesante si utile postate pe blogul dumneavoastra. dar ca si o paranteza , ce parere aveti de cazarea in regim hotelier ?. a course in miracles
REHMAN
REHMAN Jun 12
we always buy our dog supplies at least once a week from the local pet store. “ mattress cleaning newcastle
REHMAN
REHMAN Jun 16
find dining might be expensive but the menu and service is always the best. https://bk8vn.ink
REHMAN
REHMAN Jun 16
I require the majority of the records, Have a preference for seriously favored, We really wish for addiitional information and facts over it, while it is definitely rather great., L8rs used only for documenting. https://nhacaip3.name
REHMAN
REHMAN Jun 16
i would be busy again doing some home decors this coming christmas, i’d be buying some new decors for the season;; https://kakalive.fun/
REHMAN
REHMAN Jun 17
i am a movie addict and i watch a lot of movie in just one night, the greatest movie for me is Somewhere In Tome, https://thabet77.ink/
REHMAN
REHMAN Jun 21
Adding to my bookmarks thanks, needed some more pictures maybe. Aztec Powernudge
REHMAN
REHMAN Jun 21
Awesome! I appreciate your input to this matter. It has been insightful. my blog: how to eat a girl out https://i9bet.lol/
Pages: 1 2 »