Plugin Release New page: MyBB Contact Form with reCAPTCHA
Author Message Action
Andrew F.

Posts: 221

An updated contact form page that supports the default MyBB CAPTCHA and reCAPTCHA.

[Image: MyBBStyles_ContactUs.png]



This is a page for MyBB Page Manager -

Installation instructions:
  1. Login to your Admin CP and navigate to Configuration > Page Manager > Import Page. Select the contactPage.xml file to import.
  2. To enable page, go to the "Manage Pages" tab and edit the Contact page. Set the last option "Page enabled?" to "yes" and save changes.
  3. The page will be created at the url: http://www. yourforum .com/misc.php?page=contact
  4. Set CAPTCHA method in board configuration (Configuration > Settings > General Configuration > CAPTCHA Images for Registration & Posting). You can learn about and register your site for a free reCAPTCHA key set (public and private) here:
  5. Change the wording of the text displayed above the CAPTCHA. Configuration > Languages > Edit Language Variables > member.lang.php > verification_note replace with "Please enter the text contained within the image into the text box below it."
  6. To modify the footer "Contact Us" link, navigate to Configuration > Settings > General Configuration, change the "Contact Us Link" field to the contact form url.

  • Use a drop-down selection for the subject: Post #6
  • Capture IP address and user agent of emailer: Post #13
Post: #1
17-04-2012, 02:36 PM
Andrew F.

Posts: 221

Here is a tutorial of how to use the MyBB CAPTCHA class, which supports the default MyBB CAPTCHA and Google's reCAPTCHA.

First include the MyBB CAPTCHA class file.
require_once MYBB_ROOT.'inc/class_captcha.php';

Then build the CAPTCHA and assign the html to the $captcha variable. You can re-use the post_captcha/post_captcha_recaptcha templates or make your own.
// Create CAPTCHA if enabled and only for guests
if($mybb->settings['captchaimage'] && !$mybb->user['uid'])
	$form_captcha = new captcha(true, "post_captcha"); //use the post_captcha (type 1) or post_captcha_recaptcha (type 2) template
	$captcha = $form_captcha->html;

Insert {$captcha} into the desired template/html for it to be displayed.

Finally, check if the input entered into the CAPTCHA is correct after the submit button has been pressed.
// post processing
if($mybb->input['action'] == 'do_email' && $mybb->request_method == 'post')
	if($mybb->settings['captchaimage'] && !$mybb->user['uid'])
		if($form_captcha->validate_captcha() == false)
			// CAPTCHA validation failed, handle the error
			$errors[] = $lang->error_regimageinvalid;
Post: #2
18-04-2012, 04:08 PM

Junior Member
Posts: 1

I am a noob who can't understand what to do with that xml file & how to configure mybb captcha settings, please help !!!
Post: #3
04-05-2012, 09:24 AM
Andrew F.

Posts: 221

Hi blackhatwarrior, I have added more detail to the installation instructions in the first post.

Let me know which steps are causing you problems.
Post: #4
21-05-2012, 01:15 AM

Junior Member
Posts: 2

I like the plugin, but think you can do it like this:

I would appreciate if you can 001_smile
Post: #5
04-06-2012, 03:27 AM
Andrew F.

Posts: 221

Sure, you can use a drop down menu instead of a text box for the subject/issue field. Just make the following two modifications to the contact page.

<td width="40%" class="trow1"><strong>{$lang->email_subject}</strong></td>
<td width="60%" class="trow1"><input type="text" class="textbox" size="50" name="subject" value="{$subject}" /></td>

Replace with the drop down options:
<td width="40%" class="trow1"><strong>Issue:</strong></td>
<td width="60%" class="trow1">
<select name="issue">
<option value="Suggestions">Suggestions</option>
<option value="Advertisement requests">Advertisement requests</option>
<option value="Other">Other (specify in message)</option>

		$errors[] = $lang->error_no_email_subject;

Replace with:
	$subject = $mybb->input['issue'];
Post: #6
04-06-2012, 08:10 AM

Junior Member
Posts: 1

I am developing the website for my Company.
This information is very useful for me in order to correct membership requests.
Post: #7
05-06-2012, 05:47 AM

Junior Member
Posts: 3

Hey man, sorry to bother you but I just can't get the reCAPTCHA section of the form to work. I have captcha enabled for posting and registring, but it just won't load into the form template...I can't for the life of me figure out why Sad

I tried to add the code you have specified above, but it just seems to break the form (obviously something I'm doing wrong, not a problem with the code), but I don't really know where I'm supposed to put it/what I'm doing wrong.

When you say MYBB_ROOT in the first line of code you mention, does this need to be edited to the actual root of my domain, or left as it is? My forum is on my homepage, so in this case would I just use a '/'

Sorry if these questions are really obvious :S
Sorry, I meant have just sent you some gibberish, I was testing the 'demo' contact form you have linked to, but that doesn't seem to show cpatcha either?
Post: #8
14-06-2012, 08:23 AM
(This post was last modified: 14-06-2012, 08:43 AM by RoryT.)
Andrew F.

Posts: 221

Hey mate, the captcha only shows to guests (those not signed in, there is an assumption that registered and logged in members are human and do not need to complete a captcha).

You don't need to worry about adding the code in my second post, it was just to try to explain important parts of what is already in contactPage.xml and for those that want to add it to other pages they create (MYBB_ROOT should be left as is).
Post: #9
14-06-2012, 09:09 AM

Junior Member
Posts: 3


I just figured this out myself, sorry for being an idiot! Thanks for your quick reply though 001_smile

I have a couple of other questions that you may or not be able to help with - how are you dictating where the messages are sent to when the user sends a message via the 'Contact' form? I.e. how do you specify the email address the messages are being sent to?

My next question is about rewriting the URL - so by default this pages is at -

I have added the following Rewrite Rule:

RewriteRule ^Page-([^./]+)$ /misc.php?page=$1 [L,QSA,NC]

However, users aren't being directed to the rewritten URL, but it still exists ( )...should the rewrite rule not set the friendly URl as the default?

Sorry, I've never really dealt with rewriting URLs before, so I'm not sure what I'm doing wrong.
Post: #10
14-06-2012, 09:30 AM
(This post was last modified: 14-06-2012, 09:30 AM by RoryT.)

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Release]  New page: MyBB Rules Page Andrew F. 1 44,347 06-01-2015, 07:02 PM
Last Post: 123
  [Release]  New page: MyBB Google maps v3 Andrew F. 37 66,907 13-04-2014, 08:45 AM
Last Post: MidhunVarghese

Users browsing this thread: 1 Guest(s)