When setting up a MediaWiki site, you may want to allow visitors who are not registered or authenticated in your MediaWiki site to contact you for various reasons. An example of this is, if your MediaWiki site is only editable by a few people, you can have a contact page for visitors to email you if there are any website errors or misinformation on your site. This article will explain how to download, install, and configure the MediaWiki ContactPage extension.
Download the MediaWiki ContactPage extension
The ContactPage Extension is a free plugin you can get online at the WikiMedia code site. You can access it directly from the link below.
If the link is not accessible, you can follow the steps below to get the ContactPage extension files. The version of this Extension changes frequently, so you can go directly to the WikiMedia code base to find a newer version. Below are the steps to obtain the files needed to install the MediaWiki ContactPage extension.
Go to https://www.mediawiki.org/wiki/Extension:ContactPage and click the “browse code“ link in the Download section.
At the MediaWiki code review site, click “tree“ next to the version right below below the “master” version.
You will be directed to the “Code Review / mediawiki/extensions/ContactPage.git / tree” page.
Click the “raw” link next to each file to download the PHP files to your local computer.
Note! You do not need to download the .gitignore, .gitreview, README, and install.settings files as these are not needed.
Save each PHP file to your computer.
You should have the following files on your local computer.
ContactPage.alias.php ContactPage.i18n.php ContactPage.php ContactPage_body.php
Installing the MediaWiki ContactPage extension
Once you have downloaded all the necessary files for the ContactPage Extension to work, you will need to upload and configure the ContactPage extension. Below are the steps to upload and enable the ContactPage extension for MediaWiki.
- Login into your cPanel.
- Go to the File Manager. Select your MediaWiki installation directory and click Go.
- Navigate to your MediaWiki extensions folder. The path should look similar to the following.
Create a folder called “ContactPage” in the extensions folder.
Upload your ContactPage extension php files to the extensions directory like so it looks like the snapshot to the right.
Note! You do not need to upload the .gitignore, .gitreview, README, and install, settings files as these are not needed.
- Next, Navigate to the LocalSettings.php file in your MediaWiki root directory.
Select the LocalSettings.php and edit it with the code editor.
Place the following code at the bottom of your LocalSettings.php file.
require_once( "$IP/extensions/ContactPage/ContactPage.php" ); $wgContactUser = 'Admin'; $wgContactSender = $wgPasswordSender; $wgContactSenderName = 'Contact Form on ' . $wgSitename;
Save the changes.
Now Log into MediaWiki and click “Special” pages on the left hand side. On the “Special pages” page, the Contact page will be listed in the “Other special pages.”
Important! If your email for the admin is not set up and authenticated, you will need to confirm the email address in your Admin user preferences. Otherwise you will get a “No e-mal address” error on the contact page. For more information on this please see our article on This user has not specified a valid e-mail address error: MediaWiki.
As long as your email address is set up for your admin, you should see the contact form look like the snapshot to the right.
ContactPage Extension Configuration settings
The ContactPage Extension can have a few different configuration settings for customizing the form. Each setting can be added to your LocalSettings.php to enable or disable the setting. Below is a table with the available Configuration code settings.
|MediaWiki ContactPage Extension Configuration|
|$wgUserEmailUseReplyTo||Can be set to true of false. This will use the visitor’s email address as the “Reply-To” address.
Syntax: $wgUserEmailUseReplyTo[‘contactpage’] = true;
|$wgContactUser||This is set to a string of Characters. This is the username of an account in your MediaWiki that has an enabled and authenticated email address. In this example we use the Admin users email address. The email must be configured in the users Preferences. For more information on how to configure the email in the user preferences, please see our article on This user has not specified a valid e-mail address error: MediaWiki.
Syntax: $wgContactUser = ‘Your text goes here’;
|$wgContactSender||Uses the email address of the $wgContactUser for the form submittal.
Syntax: $wgContactSender = $wgPasswordSender;
|$wgContactSenderName||This is set to a string of Characters. This will display the name in the email of the receiving email address.
Syntax: $wgContactSenderName = ‘Your text goes here’;
|$wgContactRequireAll||Can be set to true of false. If this is set to true, the contact form will require the fields in the form to be filled out. The default is False.
Syntax: $wgContactRequireAll[‘contactpage’] = true
|$wgContactIncludeIP||Can be set to true of false. Enables a checkbox in the contact form that allows the senders IP address to be included in the email.
Syntax:$wgContactIncludeIP[‘contactpage’] = true;
|$wgCaptchaTriggers||Enables the captcha in the contact form.
Important! This will not work unless reCAPTCHA is enabled. For information on enabling reCAPTCHA in MediaWiki, please see our article on How to enable reCAPTCHA in MediaWiki.
Syntax:$wgCaptchaTriggers[‘contactpage’] = true;