#40474 closed defect (bug) (invalid)
wp_ajax_(action) hook doesn't work in media gallery
| Reported by: | hoandang | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Media | Version: | 4.7.3 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description (last modified by )
Step to reproduce:
- Open an image in Grid view mode
- Change image title
- Add this hook in functions.php
<?php add_action('wp_ajax_save-attachment', function($array, $int) { var_dump('save-attachment'); }, 10, 2);
Expected: A var_dump result in http network.
Actual: http always responses {"success":true}
Change History (5)
#2
in reply to: ↑ 1
@
9 years ago
Sorry, I can't see the button to edit my post. Please see the fixed image http://i.imgur.com/pGF8Rku.png
Just to elaborate the bug, the ajax request comes from media gallery not from my custom ajax request. The hook works fine with "wp_ajax_save-attachment-compat" but "wp_ajax_save-attachment"
Replying to bhargavbhandari90:
Hi @hoandang
Not able to see anything from the url you provided. Is there something you want to point out by that url
#4
in reply to: ↑ 3
@
9 years ago
- Resolution → invalid
- Status new → closed
Just double-checked the doc and it states that the "wp_ajax_(action)" hook works only with custom ajax requests, so that explains the builtin wordpress ajax requests such as "save-attachment" don't work.
The issue seems to be a missing feature in wordpress, it is not really a bug.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)

Hi @hoandang
Not able to see anything from the url you provided. Is there something you want to point out by that url