Knowledgebase

How to change the expiration time of links for email address confirmation in MediaWiki

By default, email authentication is enabled in MediaWiki. This means that in order for registered users to be able to use the email function and configure the account options related to it they have to confirm the email address that they provided for their account. When users register or change their email address they receive an email message with a link for confirming the email address. After they click on the link the email address will be authenticated. These links (also called codes and tokens) have an expiration time. By default, it's set to 7 days. After that period the token will no longer be valid and if the user hasn't confirmed their email address, they have to request another confirmation token/link (there's a button for that in the options for account preferences).

If you want to, you can change the expiration time of these email confirmation links. This can be done by adding the variable $wgUserEmailConfirmationTokenExpiry with the specified time (in seconds) to the LocalSettings.php file of your MediaWiki. For example, if you add the following on a new line at the end of LocalSettings.php:

$wgUserEmailConfirmationTokenExpiry = 3600 * 24 * 10;

the expiration time of email confirmation tokens/links will be set to 10 days. It's set in seconds but you can multiply different combinations of numbers to make it easier to configure. In our example we've specified the seconds per hour (3600 seconds in one hour), multiplied by 24 hours in one day, multiplied by 10 days. You can also specify the total number for the seconds. For example, if you add:

$wgUserEmailConfirmationTokenExpiry = 864000;

this will set the expiration time to 864000 seconds; that's the equivalent of 10 days.

The LocalSettings.php file that you have to edit is in the root MediaWiki folder on your MediaWiki hosting account. Assuming that your MediaWiki is installed directly in the public_html directory on the account, meaning the frontend is accessible at yourdomain.com, then the path to the file in relation to that directory will be public_html/LocalSettings.php. HostKnox customers can edit files on the account with the File manager of the Pixie control panel. Another way you can do it is to download the file on your local computer, edit it with a text editor (e.g. Notepad ++) and upload it back overwriting the old file.

Other articles related to email authentication that you may find useful:

Was this answer helpful?

 Print this Article

Also Read