WordPress.org

Ready to get started?Download WordPress

Forums

How to redirect to the comment form after error (7 posts)

  1. igorlaszlo
    Member
    Posted 1 year ago #

    Hi,

    i use twentyeleven child theme, wp 3.4.2

    I made a custom error page for validation error of the comment form (instead of wp-comments-post.php... tutoriel here). Now, i would like to add the link which redirects the visitor to the comment form to be able to correct his/her fault.

    How can i do it ?

  2. tomontoast
    Member
    Posted 1 year ago #

    Use wp_get_referer to make a link which the user can click to take them back to the previous page.

  3. igorlaszlo
    Member
    Posted 1 year ago #

    Thanks, i will look at it. I do not know too much about php, hopefully it helps :)

  4. igorlaszlo
    Member
    Posted 1 year ago #

    I tried to place the code <?php wp_get_referer() ?> in the body but it does not work :

    <?php get_header(); ?>
    
    <div id="primary">
    		<div id="content" role="main">
    				<div class="entry-content">
                                    <?php echo $message; ?>
    		                <?php wp_get_referer() ?>
                    </div>
            </div>
    </div>
    
    <?php get_footer(); ?>

    Can someone explain how i can place a link redirecting to the referring page ?

  5. tomontoast
    Member
    Posted 1 year ago #

    Try

    <?php if(wp_get_referer()){ ?><a href="<?php echo wp_get_referer(); ?>" title="Go back">Go back</a>
    <?php } ?>
  6. igorlaszlo
    Member
    Posted 1 year ago #


  7. igorlaszlo
    Member
    Posted 1 year ago #

    YOU ARE GENIOUS !!! :) , it works...

    I am asking myself why WP did not think about it, it is evident that when i make a mistake on the form, i go back to retry...

    Thanks a lot again !

Topic Closed

This topic has been closed to new replies.

About this Topic