Skip to content

Instantly share code, notes, and snippets.

@mcguffin
Created March 23, 2015 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcguffin/c0382448518a2b68e94a to your computer and use it in GitHub Desktop.
Save mcguffin/c0382448518a2b68e94a to your computer and use it in GitHub Desktop.
WP-Recaptcha-Integration: A working custom comment form.
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if (is_user_logged_in()) : ?>
<p>
<?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'shoestrap'), get_option('siteurl'), $user_identity); ?>
<a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'shoestrap'); ?>"><?php _e('Log out &raquo;', 'shoestrap'); ?></a>
</p>
<?php else : ?>
<div class="form-group">
<label for="author"><?php _e('Name', 'shoestrap'); if ($req) _e(' (required)', 'shoestrap'); ?></label>
<input type="text" class="form-control" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" <?php if ($req) echo 'aria-required="true"'; ?>>
</div>
<div class="form-group">
<label for="email"><?php _e('Email (will not be published)', 'shoestrap'); if ($req) _e(' (required)', 'shoestrap'); ?></label>
<input type="email" class="form-control" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" <?php if ($req) echo 'aria-required="true"'; ?>>
</div>
<div class="form-group">
<label for="url"><?php _e('Website', 'shoestrap'); ?></label>
<input type="url" class="form-control" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22">
</div>
<?php endif; ?>
<div class="form-group">
<label for="comment"><?php _e('Comment', 'shoestrap'); ?></label>
<textarea name="comment" id="comment" class="form-control" rows="5" aria-required="true"></textarea>
</div>
<?php do_action('print_comments_recaptcha'); ?>
<p><input name="submit" class="btn btn-primary" type="submit" id="submit" value="<?php _e('Submit Comment', 'shoestrap'); ?>"></p>
<?php comment_id_fields(); ?>
<?php do_action('comment_form', $post->ID); ?>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment