Welcome to WebmasterWorld Guest from 54.145.176.120

Forum Moderators: rogerd

Message Too Old, No Replies

Hooking in to "comment post" Action

   
2:58 pm on Jun 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm using wordpress to build a site that contains a number of articles that I want students to read and then post a comment on. Once the comment is posted, I want the main page of the site to then display that post name with a strike-through, indicating it is an article which that particular user has already read.

I'm using...
add_action('comment_post','show_this_post_as_read');

...where show_this_post_as_read is a function which takes no arguments.

All of my functions, database calls, etc are working IF I tie the execution of the above function to some other API action. For instance...
add_action('loop-end','show_this_post_as_read');
works fine. The site indicates a post as being read after a user visits a particular post. But I don't want posts that users just clicked into to be marked as having been read. I want it tied to whether or not they commented, as this is a better indication of whether or not they really read the post.

For some reason, hooking to the "comment_post" action is not working for me. I have literally SCOURED the web looking for some insight into why this is not working and have found nothing.

If anyone has ever met with success using this hook in Wordpress, would you mind helping me figure out what I'm missing?

Thanks,
cEM
1:25 pm on Jun 11, 2012 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I haven't actually done what you're trying to do but in looking at the WP documentation it looks like 'comment_post' has multiple return values ( [codex.wordpress.org...] ) which leads me to wonder what the triggers are in your function?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month