Title: Redirect First Comment
Last modified: August 20, 2016

---

# Redirect First Comment

 *  Resolved [Christopher Roberts](https://wordpress.org/support/users/christopherrobertswordpress/)
 * (@christopherrobertswordpress)
 * [14 years ago](https://wordpress.org/support/topic/redirect-first-comment/)
 * Hi everyone, my name is Christopher and I am a member of the admin team for [Technology Bloggers](http://www.technologybloggers.org/).
 * I am trying to redirect users who post their first comments on the blog to this
   URL: [http://www.technologybloggers.org/first-comment/](http://www.technologybloggers.org/first-comment/)
 * I know this plugin can do it ([Comment Redirect by Yoast](http://wordpress.org/extend/plugins/comment-redirect/))
   and it is what we currently use, however we have to slim down our plugin list,
   as the memory available to us is just 20MB, and the blog is not running smoothly.
 * I am sure it is possible by editing comment-template.php and adding something
   like
 *     ```
       function comment_redirect( $url, $comment ) {
       		$cc = get_comments( array( 'author_email' => $comment->comment_author_email, 'count' => true ) );
   
       		if ( 1 == $cc )...
       ```
   
 * Any thoughts on how we can do this?
 * Christopher

Viewing 1 replies (of 1 total)

 *  Thread Starter [Christopher Roberts](https://wordpress.org/support/users/christopherrobertswordpress/)
 * (@christopherrobertswordpress)
 * [14 years ago](https://wordpress.org/support/topic/redirect-first-comment/#post-2772727)
 * Thanks to a post by [Boutros AbiChedid](http://bacsoftwareconsulting.com/blog/index.php/wordpress-cat/how-to-redirect-first-time-commenters-in-wordpress-without-a-plugin/)
   I have found a way!
 * Add this code to functions.php – I added it right below `<?php`
 * Here is the code – just replace YOUR URL with your first comment redirect page
 *     ```
       /*START FIRST COMMENT*/
   
       /************************************CODE-2*******************************
       * @Author: Boutros AbiChedid
       * @Date:   May 14, 2012
       * @Websites: bacsoftwareconsulting.com/ ; blueoliveonline.com/
       * @Description: Redirect to a 'Thank You' page only after the FIRST
       * Post/Page Comment.
       * @Tested on: WordPress version 3.3.2
       **************************************************************************/
   
       function redirect_after_first_comment($url, $comment) {
       	$comment_count = get_comments(
       						array(
       						'author_email' => $comment->comment_author_email,
       						'count' => true
       						)
       					);
       	//Check if this is the first Comment (based on the Commenter email)
       	if ( $comment_count == 1 ) {
       		//Redirect URL for first time Commenters.
       		wp_redirect('YOUR URL'); /* MODIFY the Path Accordingly */
        		exit();
       	}
       	//Else, return the current post for repeated commenters.
       	return $url = get_comment_link();
       }
       //Hook the 'first_comment_redirect' function to the 'comment_post_redirect' filter action.
       add_filter( 'comment_post_redirect', 'redirect_after_first_comment', 5, 2);
   
       /*END FIRST COMMENT*/
       ```
   
 * Hope this helps someone.

Viewing 1 replies (of 1 total)

The topic ‘Redirect First Comment’ is closed to new replies.

## Tags

 * [comment](https://wordpress.org/support/topic-tag/comment/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)
 * [Technology Bloggers](https://wordpress.org/support/topic-tag/technology-bloggers/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [Christopher Roberts](https://wordpress.org/support/users/christopherrobertswordpress/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/redirect-first-comment/#post-2772727)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
