Support » Fixing WordPress » insert comment error messages on page?

  • For comments on my wordpress blog, most of the fields are required. How can I ensure that when the field is filled in incorrectly, the error message will be inserted on the page (using my wordpress theme) rather than throwing a virtually blank page showing only the error message?

    -EMorris, wp 2.8.5, mySQL 4.1.22, php4.4.7, firefox 3.0.15, WinXP

    comment plugin: WP-Gatekeeper

    etherwork.net/blog/ (URL purposely unlinked to keep spammers at bay)

    edit: Please note that I’ve searched this forum and googled as best I can for the answer to this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ejm

    (@llizard)

    Excuse me for replying to myself…

    With the help of the following pages, I have come up with a solution.
    http://wordpress.org/support/topic/109477?replies=10
    http://stackoverflow.com/questions/482370/how-to-customize-wordpress-comment-error-page

    Sure, the error messages are not actually appearing on the pages themselves, but it’s still not an unreasonable fix. Here’s what I did:

    1. Before doing anything I made sure that I had backup copies of the files I was changing so I could put them back in case something bad happened.
    2. In /wordpress/plugins/wp-gatekeeper.php, I changed “die” to “wp-die” in the following spot:

      if (!gatekeeper_run_gauntlet($key,$answer)) {
      die( __(‘Sorry, posting has been closed for the time being.’) );’

      This is the change I made:

      if (!gatekeeper_run_gauntlet($key,$answer)) {
      		wp_die( __('Congratulations. You have just confirmed that you are a robot. If you are indeed a person, please use your browser buttons to go back and try again.') );
    3. Using /wordpress/wp-content/db-error.php as a template, I made the following change in wp-includes/functions.php:
      I located

      if ( ( $wp_locale ) && ( ‘rtl’ == $wp_locale->text_direction ) ) $text_direction = ‘rtl’;
      ?>
      <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
      […snip…]

      </head>
      <body id=”error-page”>
      <?php endif; ?>
      <?php echo $message; ?>
      </body>

      and changed it to

      if ( ( $wp_locale ) && ( 'rtl' == $wp_locale->text_direction ) )
      $text_direction = 'rtl';
      ?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title><?php echo $title ?> WordPress &rsaquo; Error</title>
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <style type="text/css">
      <!--
      #wordpress {
        width: 95%;
        background: #f0f8ff;
        color:#009;
        margin: 0 auto;
        margin-bottom:40px;
        border: 1px solid #300;
        padding:10px;
        text-align: left;  /* IE 5.5 hack part II */
      }
      
      #wordpress h1 {
      
        display:inline;
        color: #006;
        font-weight: lighter;
        font-size: 1.8em;
       }
      #wordpress h2 {
        font-size: 1.8em;
       }
      #wordpress #logo {
        padding:5px;
        background:#fff;
        margin-bottom: 2em;
       }
      #wordpress ul {list-style: none; margin:0; margin-left:30px;padding:0;}
      #wordpress li {display:block; background:transparent; color:#600; margin-bottom:12px; padding:0 0 5px 27px;}
      -->
      
      </style>
      
      </head>
      <body>
      
      <div id="wordpress">
      <h1 class="logo"><img alt="WordPress" src="/images/wp_logo147x25.png" width="147" height="25" /></h1>
      
      <?php endif; ?>
      	<?php echo $message; ?>
      </div>
      </body>

    Of course, this means that all error messages called up by wp-die will be housed in that particular page style but it really doesn’t matter to me if my admin error messages suddenly look that way. That’s aok by me.

    Unless someone thinks this may cause some sort of security breach….

    Thread Starter ejm

    (@llizard)

    Addendum: I am reluctant to change this topic to “resolved” because I’d still like to know how to insert the error messages on the comment page so the legitimate visitor who has made a typo doesn’t have to go back one page to access the comment section.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘insert comment error messages on page?’ is closed to new replies.