I am trying to create a plugin or function that increments a counter in the usermeta table for the comment author that I use in other parts of my site. Basically, I need a count of the total number of comments per user, and rather than doing a bunch of Database queries to figure it out, I wanted to add an action every time a comment was submitted that updates the comment count.
I have never written a plugin before and I am having a hard time understanding what data gets passed to my function when I use:
add_action (‘comment_post’, ‘MY_FUNCTION_NAME’);
where “MY_FUNCTION_NAME” is the name of the function that I want to run.
Normally, when I need to do some WP Hacking, I can figure it out by reading the documentation, but there doesn’t seem to be much for this. All I really need to know is how to determine (inside the function) what the user_id of the comment author is.
- The topic ‘Increment a Counter after Comment is published’ is closed to new replies.