• Resolved Jiri Hon

    (@jirihon)


    Dear WordPress community,
    please, does anybody know why the following code does not work? It should output Hello world when loading image editor with AJAX, but does nothing.

    function say_hello()
    {
    	var_dump("Hello world");
    }
    add_action( 'wp_ajax_image-editor', 'say_hello' );

    Is there something I’m missing?

    Thank you a lot,
    Jiri Hon

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I can’t comment on using that action, I’m unfamiliar with it. Your code is flawed though, var_dump() only works when passed a variable, it doesn’t work on static strings. Either assign the string to a variable which is in turn dumped, or simply use echo or printf(), like so:
    echo 'Hello World';

    Thread Starter Jiri Hon

    (@jirihon)

    I admit that this somewhat weird use case of var_dump, but it actually works also on literals.

    Please, is anybody experiencing the same problem with wp_ajax_image-editor hook? At least one another user noticed the same issue – I found this comment in Arlima plugin source code:

    // The following action is not possible to hook into wtf???
    // add_action('wp_ajax_image-editor', array($this, removeImageVersions'));
    Thread Starter Jiri Hon

    (@jirihon)

    Resolved. The default hook for wp_ajax_image-editor action executes wp_die() so nothing can be done after the default hook, indeed it has high priority. The solution is to define the custom hook with higher priority.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Why can't hook into wp_ajax_image-editor action?’ is closed to new replies.