WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If user is editor, this function auto-shoots when user visits his dashboard!

How is this possible? This function should only work when user successfully posts comment, so what is happening? could be wordpress bug?

function redirect_after_comment($location)

//This should run only when comment is confirmed. But for user level Editor, this function auto shoots!

  1. User role is EDITOR
  2. user logins, goes to dashboard.
  3. Anything inside this function runs. For example return...
share|improve this question
I'm not sure I understand your question. You mention get_comment_link() in the title, but reference redirect_after_comment() in the question body. Also: can you provide a bit more detail about what actually happens? – Chip Bennett Nov 15 '12 at 19:32
Could be one of the dashboards widgets("recent comments" maybe?). try if(is_admin()) return; as first line of function – Mridul Aggarwal Nov 15 '12 at 19:37
@ChipBennett redirect_after_comment is just my function name, isn't it? – Sandro Dzneladze Nov 15 '12 at 20:28
@MridulAggarwal Impossible that it is widget, because this doesn't happen with admin. – Sandro Dzneladze Nov 15 '12 at 20:28
@MridulAggarwal I outlined details. – Sandro Dzneladze Nov 15 '12 at 20:30
up vote 1 down vote accepted

It appears that you're intending to redirect the user to a certain page, after the user posts a comment?

If so: why are you hooking into get_commenet_link for this redirect? The get_comment_link() function is intended to return the permalink to a given comment. The get_comment_link filter is intended to filer the comment permalink returned by get_comment_link(). By hooking into get_comment_link, your callback is going to fire everywhere that get_comment_link() is called. Here is the filter inside of the function:

return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args );

I would recommend using a more appropriate hook related to the comment-posting process, such as comment_post.

share|improve this answer
It still makes no sense to me, but comment_post hook seems better :) – Sandro Dzneladze Nov 16 '12 at 7:27
What still makes no sense? We'll try to help make things more clear. :) – Chip Bennett Nov 16 '12 at 13:04
Well, the fact that get_comment_link runs when user Editor logs into dashboard seems a bit odd. Btw, I use that function to hook into url redirect after comment, so user is redirected to correct language website after submission. Unfortunately qtranslate doesn't do it out of the box. So I divided my function into two parts, 1 part which was breaking dashboard went into comment_post and url manipulation I left in get_comment_link and it seems to work now. ty. – Sandro Dzneladze Nov 16 '12 at 14:47
I assume that get_comment_link filters get applied when the dashboard is rendered because comment links are being displayed on the dashboard, somewhere. But I'm still curious why you chose that particular filter, since the get_comment_link() template tag has nothing to do with the comment-posting process/execution. – Chip Bennett Nov 16 '12 at 14:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.