Support » Fixing WordPress » Comment form features…

  • I am working on styling my comment form and trying to get it to function the way I would like it to.

    My blog is located at

    The form looks the way I want to for the most part. However, I would like it to recognize someone if they are logged in to WordPress and automatically post their comment.

    Then, if they are not logged in I would like it to show somehow that the post is awaiting moderation without posting the message that they are submitting.

    Is there a way to do this… or is there a theme that someone could point me to that does this so that I can compare the source code?

    All help is appreciated!!!

    Code for comment page is below:

    <?php // Do not delete these lines
    	if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die ('Please do not load this page directly. Thanks!');
            if (!empty($post->post_password)) { // if there's a password
                if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
    				<p class="nocomments">This post is password protected. Enter the password to view comments.<p>
    		/* This variable is for alternating comment background */
    		$oddcomment = 'alt';
    <!-- You can start editing here. -->
    <br /><br /><br />
    <div id="commentback">
    <?php if ($comments) : ?>
    	<h3><?php comments_number('No Comments', 'One Comment', '% Comments' );?> on “<?php the_title(); ?>”</h3> <br />
    	<ol id="comments">
    	<?php foreach ($comments as $comment) : ?>
    		<li class="comment <?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    			<cite><?php comment_author_link() ?></cite> Says:
    			<?php if ($comment->comment_approved == '0') : ?>
    			<em>Your comment is awaiting moderation.</em>
    			<?php endif; ?>
    			<br />
    			<?php comment_text() ?>
    			<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a></small>
    			<br />
    	<?php /* Changes every other comment to a different class */
    		if ('alt' == $oddcomment) $oddcomment = '';
    		else $oddcomment = 'alt';
    	<?php endforeach; /* end for each comment */ ?>
     <?php else : // this is displayed if there are no comments so far ?>
      <?php if ('open' == $post->comment_status) : ?>
    		<!-- If comments are open, but there are no comments. -->
    	 <?php else : // comments are closed ?>
    		<!-- If comments are closed. -->
    		<p class="nocomments">Comments are closed.</p>
    	<?php endif; ?>
    <?php endif; ?>
    <?php if ( comments_open() ) : ?>
    <div id="commentsection">
    <h3>Write a comment</h3><br />
    <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    <p><label for="author">Name:</label><br />
    <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" /><input type="hidden" name="comment_post_ID" value="<?php echo $post->ID; ?>" />
    <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($_SERVER['REQUEST_URI']); ?>" /></p>
    <p><label for="email">E-mail:</label><br /><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="28" tabindex="2" /></p>
    <p><label for="url">Website:</label><br /><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" /></p>
    <p><label for="comment">Your comment:</label><br />
    <textarea name="comment" id="comment" cols="66" rows="7" tabindex="4"></textarea></p>
    <p><input type="image" id="submit" src="" alt="Submit" /></p>
    <?php do_action('comment_form', $post->ID); ?></form>
    <?php else : // Comments are closed ?>
    <?php endif; ?>

  • The topic ‘Comment form features…’ is closed to new replies.