On a new wordpress site I realise that sometimes when testing the comments feature for posts that the “your comment is awiting moderation” message does not appear.
When a comment is posted, the url of the page when it refreshes contains an anchor to the wrapping div of the new comment. In that div instead of showing the comment when a normal user makes the comment, a message “your comment is awaiting moderation” normally appears.
When this problem occurs though, although the anchor is still in the url of the returning page, the entire comment element isn’t in the html. This means that the anchor point doesn’t exist, so when the page loads, instead of jumping down to the last comment point it stays at the very top.
Repeating this problem reliably has been incredibly difficult. There was a hunch to start with that it occured only for certain browsers. Then when I realised that the returning html from the php simply was missing the comment just made (or its wrapper and awaiting message at least) I realised something very fundamental had to be going on.
My hunch is that this is beccause my test messages (which often contain just a few words or characters and aren’t really accurate representations of a real message) were caught by Askimet (yes its installed and running) and marked as spam. I’ve found some of my tests as marked as spam and so I’ve concluded this is probably the reason for the awaiting moderation message not appearing.
However I’ve also definitely not had the message appear and the test comment I made was cleared as ok by askimet. So I’m not sure if my assumption is completely/at all correct.
Does anyone know about the internal workings of this and can confirm why this message may not appear?
I got around this by handling it all in JS / Jquery.
On a jQuery document ready clause I look for a specific type of anchor on page load and if that is present I assume that a message has just been posted. I then using jQuery display a nice little alert message up top of the page.
For the purpose of the sample code below I’ve used a standard JS alert function call to display the msg so you could alter this and make your own msg displaying function.