Forums

comment_post not triggering? (2 posts)

  1. SharkBait
    Member
    Posted 3 years ago #

    I am writing a small plugin that needs to execute after someone has posted a comment and I don't think it is triggering properly.

    Is there an easy way to test it?

    function myfunction($comment_ID) {
      update_option('test_respsonse', 'This should be saved');
    }
    add_action('comment_post', 'myfunction');

    Technically shouldn't myfunction() get executed when someone submits a comment?

    On the admin page for the plugin I have something to this effect:
    echo "Repsonse: ". get_option('test_response');

    But it does not show any changes so I am assuming my add_action() hook isn't executing properly.

    What am I doing wrong?

  2. Djay77
    Member
    Posted 3 years ago #

    Hi,

    I have exactly the same problem.
    The add_action('comment_post') didn't work

    A very simple and visible example

    add_action('comment_post ', 'toto');
    function toto()
    {
        die('djay');
    }

    Nothing happened :(

    /////
    Forget what i said, i putted a space in add_action('comment_post ') :D

Topic Closed

This topic has been closed to new replies.

About this Topic