Forums

Redirecting after comments have been posted (7 posts)

  1. Anonymous
    Unregistered
    Posted 7 years ago #

    On my website, after someone has posted a comment, the URL in the address bar is that of the file 'http://joeblade.com/wp/wp-comments-post.php' - it can cause double-posts if someone then presses 'refresh'. Is there a way of getting the post-comment URL to be http://joeblade.com/index.php?p=88 instead, to avoid this problem?

  2. zach
    Member
    Posted 7 years ago #

    Same here. Anyone?

  3. midori
    Member
    Posted 7 years ago #

    Huuuh, I am not sure I understand, but... try to find the *form* of the comment, and check for action="something" in the <form> tag. that's the place the user will be taken after he adds a comment. Although I do not know if changing it will keep the comments form functioning.

  4. James
    Happiness Engineer
    Posted 7 years ago #

    It will, for lack of better words, kill the comments, because WP needs to call on wp-comments-post.php to actually post the comment in the database. If you redirect them to index.php?p=88, hitting the post comment button will do exactly that, redirect them to index.php?p=88, but it won't post the comment. You'll just have to find out who's refreshing while they post a comment.

  5. Anonymous
    Unregistered
    Posted 7 years ago #

    macmanx, the original post was about redirecting AFTER comments are posted.
    these days it is a common programming practice to redirected after form submissions as the original author asks to avoid double posting, which is fairly common.
    someone should submit this as a bug and ensure redirects happen after all form submissions.

  6. James
    Happiness Engineer
    Posted 7 years ago #

    From what I can tell, la_haine is saying that he/she does not want the browser to go to 'http://joeblade.com/wp/wp-comments-post.php', because hitting a refresh could repost the comment. That is true, but the browser needs to access this file to post the comment. The way everything works by default is you go to 'http://joeblade.com/index.php?p=88' to enter the comment, when you post the comment you're sent to 'http://joeblade.com/wp/wp-comments-post.php' so that it's entered into the database, and then you are sent back to 'http://joeblade.com/index.php?p=88'. You cannot take wp-comments-post.php out of the loop.

  7. _g_
    Member
    Posted 7 years ago #

    I think it shudn't be hard...just needs little bit of js.
    You can add a hidden type in the comments form called "redirect" or whatever u want and put its value = index.php?p=88 and then in the wp-comments.php (same file) check if the form was submitted and the redirect value exists....then use the php header to redirect to the value of redirect.
    may be the code in the following link (google's cached result) will help u to get started
    http://216.239.57.104/search?q=cache:822bXvQfbIEJ:www.clickfire.com/viewpoints/articles/webdevelopment/create_php_form.php+redirect+form+php&hl=en

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.