Title: Comments Form Advanced Coding (php)
Last modified: August 20, 2016

---

# Comments Form Advanced Coding (php)

 *  [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/)
 * I’m trying to alter the comment form in my WordPress blog. My goal is to let 
   only my phpBB users comment on the posts. I use the phpBB login system for my
   entire site. So here’s my plan. I’m going to put an ‘if statement’ around the
   comment form in WordPress. Basically like this:
 * At the top of the file:
 *     ```
       <php?
       //include phpBB stuff
       ?>
       ```
   
 * Then around the comment form:
 *     ```
       If user->registered
       {
            Show comment form
       }
       else
       {
          Show message with link to login
       }
       ```
   
 * Then I’m going to alter the variables sent to the database. I plan on hiding 
   all but the comments box and then filling the other variables manually. Something
   like this:
 *     ```
       $comment_author = $user->data['username']
       $comment_author_email =$user->data['user_email']
       $comment_author_url = the url to the users porfile
       $comment_content = no change here
       ```
   
 * But I’m running into an issue. What file is the comment form in? Is it even a
   php file? Before I waste time, does anyone think this is going to be possible?
 * *Edit*
    Forgot to mention, I’m going to have it set so anyone can comment in 
   the WordPress settings. I think that’s the only way I’ll be able to make this
   work.

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156345)
 * It looks like this is going to be possible. Anyone with experience in php, please
   give me your opinion! This is an example of how to limit comments to only those
   who are members of your website. In this example I’m going to use phpBB members
   as they’re integrated throughout my site. I haven’t tested it yet, but this is
   what I’ve got so far.
 * *Note* If you’re going to test this, back up every file you before you touch 
   it. Like I said, I don’t know if it will work. I will test it and post the result
   later.
 * This is the comment_form() function. From what I understand, it’s called to display
   the comment form at the bottom of blog posts. It’s located in wp-includes/comment-
   template.php on line 1509. Some changes will need to be made to it later.
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * It looks like two files need to be changed in order to allow only the members
   of your site to comment. These two files are as follows:
 * 1. wp-content/themes/ {Your Theme Name Here} /comments.php
    2. wp-includes/comment-
   template.php
 * First things first, add the following to the top of comments.php. This is for
   phpBB users. If you use your own login system, include the proper files instead.
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * It will need to be changed to this:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Next up is comment-template.php. I don’t think it’s necessary, but go ahead and
   include the php for session management at the top of this file too. Then make
   the following changes to comment_form() (line 1509).
 * Find:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Replace with:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * These changes insert your users info into form. It also makes them hidden so 
   changes cannot be made. If you want them to make changes, change type=”hidden”
   to type=”text”. Also, a link is displayed in the value of the url field. This
   is a link to the users profile. You may need to change it depending on the location
   of profiles.
 * But, I’ve no idea if this will work. Just ideas. If anyone has experience with
   this, please comment on my idea! I would love the input/advice!
 * References for information:
    [http://codex.wordpress.org/Function_Reference/comment_form](http://codex.wordpress.org/Function_Reference/comment_form)
   [http://devpress.com/blog/using-the-wordpress-comment-form/](http://devpress.com/blog/using-the-wordpress-comment-form/)
 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156356)
 * Errors found so far:
 * Error 1:
    Fatal error: Cannot redeclare make_clickable() Fix: [http://www.phpbb.com/community/viewtopic.php?f=46&t=2100992](http://www.phpbb.com/community/viewtopic.php?f=46&t=2100992)
 * Error 2:
    Fatal error: Call to a member function sql_query() on a non-object 
   in cache.php Fix: [http://www.phpbb.com/community/viewtopic.php?f=71&t=1016345](http://www.phpbb.com/community/viewtopic.php?f=71&t=1016345)
 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156373)
 * Okay, got it all working. Only minor changes to what I had above. There are probably
   better and more secure ways of doing this, but I don’t know enough to implement
   them. Anyway, onto the changes!
 * In file common.php
 * Place this at the top of the page:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Then find:
    `<?php comment_form(); ?>`
 * Replace with:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Then in comment-template.php
 * Find:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * That’s it. Now only users logged into your site can comment. This example assumes
   you use phpBB to handle your members, but only minor changes would need to be
   made if you use your own member system. I will be making some small changes after
   a few tests. I’m going to make the name, email, and url items hidden. Very simple
   to do. Then only the comments box will show.
 *  [chadrew](https://wordpress.org/support/users/chadrew/)
 * (@chadrew)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156472)
 * Very interesting, I was just looking for a way to make forum users able to comment
   on WordPress posts, without messing with duplicate databases and bridge plugins.
   Does this work by checking for PHPBB cookie?
 * I’ll definitely be trying this 🙂
 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156486)
 * Yes, it checks user->data to see if the user is registered/logged in. Here’s 
   a significant change I’ve made.
 * *EDIT*
    I had some significant changes, however, a moderator decided to delete
   them… Changes are as follows: -Makes the input boxes hidden so users can’t edit
   data -Displays a message to logged in users (just like WP does)
 * If you want these simple changes, email me at [tech.inno@ymail.com](https://wordpress.org/support/topic/comments-form-advanced-coding-php/tech.inno@ymail.com?output_format=md).
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156487)
 * Do **NOT** edit core WordPress files!
 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156488)
 * Actually, this doesn’t hurt a thing. WP overrides it when a WP user is logged
   in. So if you’re logged into WordPress, it all works as normal. Really, editing
   is fine. Just BACKUP ANY FILE BEFORE YOU TOUCH IT. This is a “Hack” forum after
   all.
 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156489)
 * May I ask why all of my code has been removed? Most of it was less than 10 lines.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156490)
 * I checked. They were all over 10 lines.
 *  Thread Starter [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * (@techinno)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156491)
 * Well, now 6 days after I posted this hack, all the code has been removed. I’m
   not going back to edit every post. If you want this code, check in the official
   phpBB forum @ [http://www.phpbb.com/community/](http://www.phpbb.com/community/).
   Because this hack was designed to integrate phpBB and WP, it will be posted there
   soon. Sorry to all those who checked here. Alternatively you can email me at 
   [tech.inno@ymail.com](https://wordpress.org/support/topic/comments-form-advanced-coding-php/tech.inno@ymail.com?output_format=md).

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Comments Form Advanced Coding (php)’ is closed to new replies.

## Tags

 * [advanced](https://wordpress.org/support/topic-tag/advanced/)
 * [code](https://wordpress.org/support/topic-tag/code/)
 * [comment](https://wordpress.org/support/topic-tag/comment/)
 * [form](https://wordpress.org/support/topic-tag/form/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [phpBB](https://wordpress.org/support/topic-tag/phpbb/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 10 replies
 * 3 participants
 * Last reply from: [Tech.Inno](https://wordpress.org/support/users/techinno/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/comments-form-advanced-coding-php/#post-2156491)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
