Opened 9 years ago
Closed 9 years ago
#41228 closed enhancement (fixed)
No way to get the post ID after a comment is deleted
| Reported by: | henry.wright | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9 |
| Component: | Comments | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
If we hook to deleted_comment we get given $comment_ID but at this point the comment has been removed from the database so we can't do things like this:
$comment = get_comment( $comment_ID ); echo $comment->comment_post_ID;
Can we pass a 2nd arg to do_action()? For example:
do_action( 'deleted_comment', $comment->comment_ID, $post_id );
Attachments (3)
Change History (10)
@
9 years ago
41228.diff passes a 2nd argument to do_action(). This will allow full access to the deleted comment in hooked functions.
#3
in reply to: ↑ 1
@
9 years ago
- Component General → Comments
Replying to henry.wright:
Alternatively, the 2nd arg could be
$comment, where$commentis the (deleted) comment object.
Makes sense to me, but I think the same should be done for all the related actions, for consistency:
delete_commentdeleted_commenttrash_commenttrashed_commentuntrash_commentuntrashed_commentspam_commentspammed_commentunspam_commentunspammed_comment
Or you could use one of the hooks in wp_transition_comment_status(), e.g. transition_comment_status, which gets called on comment deletion with delete as the new status, and does pass the full comment object to the hook.
@
9 years ago
41288.2.diff addresses the related actions. Thanks @SergeyBiryukov for mentioning transition_comment_status that will come in useful :)
#4
@
9 years ago
- Milestone Awaiting Review → 4.9
I agree about adding the param to all of the hooks.
@henrywright: We're also going to need changelog entries for each of the hooks getting the new params.
@
9 years ago
Thanks for the link to the coding standards. I'll note what constitutes a significant change for next time. 41228.3.diff adds @since tags to each DocBlock.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Alternatively, the 2nd arg could be
$comment, where$commentis the (deleted) comment object.