Twitter Lock

The Twitter Lock extension for Download Monitor allows you to require users to tweet your pre-defined text before they gain access to a download.


  • Unzip and upload the plugin’s folder to your /wp-content/plugins/ directory
  • Activate the extension through the ‘Plugins’ menu in WordPress

For more information on installing and managing plugins see here


After installing the extension the first thing you should do it setup your API keys, without valid Twitter API keys the extension will not work.

Setup your API keys

Before you can start using the Twitter Lock extension you will need to setup a Twitter App and set the app's API keys in your Download Monitor settings. The following steps will guide you through the process of creating a Twitter App and obtaining it's API keys.

Step 1: Twitter's Application Management website

Go the the Twitter Application Management website (login if you're not logged in yet) and click the Create New App button.

Create a Twitter App
Click the Create New App button

Step 2: Create an application

In this step you will fill in your application details. You can fill in any name and description you like but remember users will see this when authorizing your application. Enter your website URL at the website and at callback URL fields.

Your Twitter App Details
Your Twitter App Details

Read and accept Twitter's Developer Agreement and click the Create your Twitter application button.

Your application is now created, you will be taken to the application overview screen. Before we continue to the next step (obtaining your API keys) it's important to check your application has been created with Read and write access level (1) and there's Callback URL locked is set to No (2). These settings should correct by default but it's good practice to check them before we continue. After you've confirmed these settings are correct, click the Key and Access Tokens tab (arrow).

The Twitter Application Overview Screen
The Twitter Application Overview Screen

Step 3: Obtaining your API keys

On the Key and Access Tokens page you will find your application API keys and various other application data. The two important rows here are Consumer Key (API Key) and Consumer Secret (API Secret).

Your Twitter App API keys
Your Twitter App API keys

Copy the Consumer Key (API Key) and Consumer Secret (API Secret) values and paste them into your Download Monitor - Twitter Lock settings.

Place your Twitter API keys in your Download Monitor settings.
Place your Twitter API keys in your Download Monitor settings.

That's it, your Twitter Application is now setup and your Download Monitor powered website is ready for use.

Tweet Locking your Downloads

Tweet lock your downloads by editing your download in the Download Monitor screen in your WordPress backend and check the Twitter Lock option in the Download Options metabox on the right side of the screen. After checking the Twitter Lock option a tweet message field will appear where you can enter a download specific tweet message. If no message is entered the global tweet message will be used.

Twitter Locking your Downloads in Download Monitor
Twitter Locking your Downloads in Download Monitor

Note the tweet message box has a small counter on the bottom right that will display the amount of available characters left (due Twitter's tweet length restriction).

Tweet to Unlock Download button

You can display Tweet to Unlock Download buttons anywhere on your website with the [dlm_tl_tweet_button id="DOWNLOAD_ID"] shortcode. Replace DOWNLOAD_ID with the ID of your download, you can find the download ID when editing the download in the Download Information metabox.

The shortcode will be replaced by this beautiful button:

Tweet to Unlock Button
Tweet to Unlock Button

Template Overriding

Like Download Monitor, the Twitter Lock extension comes with overridable template files. By overriding a template file you can change the HTML output of the plugin while still keeping the extension updatable. To override a template file, copy the file to your the download-monitor directory in your theme (create the directory if it doesn't exist) and modify the file you just copied to your theme any way you want. The Twitter extension comes with the following overridable template files:


The HTML for the Tweet to Unlock Button discussed in the previous chapter. Note that if you only want to change the label of the button, it's recommended to use the dlm_tl_download_button_label filter instead of overriding this template. See the FAQ at the bottom of this page for an example on using this filter.


The success screen that is displayed in the popup after a someone successfully unlocked the download. Note that this template part is different than most other templates because it's a full HTML page instead of (including <head> and <body> tags). This template file calls wp_head(); in the header so the popup styling matches your website theme. If you only want to do CSS changes to this template file, it's recommended to edit your theme's style.css file or hook into WordPress's default wp_head hook and add your custom styling instead of overriding this template file.

Customer Usage

After someone clicks the Tweet to Unlock Download button you've added via the shortcode, a popop will open. Your user will have to do the following 2 actions to unlock the download:

  1. Login into Twitter (this step is skipped is user is already logged in)
  2. Authorize your application (this step is skipped if user already authorized application)

So if a user is logged in and has already authorized your application, they will unlock the download only by click on the Tweet to Unlock Download button! After the download is unlocked the user will be redirected to a page where they can download the file.

The screen that will be displayed within the popup after the download's unlocked.
The screen that will be displayed within the popup after the download's unlocked.

Note that this screenshot is based on the current theme used when taking the screenshot, the screen will use your theme's styling. The button shown on this page will be the default Download Monitor button template which will be styled as your other Download Monitor buttons on your website. The button is using the default Download Monitor content-download-button.php template file, so you can override this template file to change the HTML output.


How long will the download stay unlocked?

The download will stay unlocked as long as your user keeps the browser open, the download will be re-locked for them when the browser is closed.

Can I tweet lock multiple downloads?

You can. Please do note that when you lock multiple downloads with the same tweet message, the tweet will only be tweeted once (due Twitter's unique tweet restriction). The user will not be notified of this, they will simply get access to the download if the tweet was tweeted or already existed.

Can I set a global unlock tweet message?

You can set a global unlock tweet at the Twitter Lock tab in your Download Monitors settings page. The Global Tweet will be used if no specific tweet message is set at a Twitter locked download.

The Global Unlock Tweet setting is located in the settings.
The Global Unlock Tweet setting is located in the settings.

How do I change the Twitter Application image?

You can set/change your Twitter Application image on the Twitter Application Management website. Edit your app and go to the Settings tab. Below your basic application settings you'll find an option to set an Application Image.

Set your Twitter Application Image
Set your Twitter Application Image

How do I change the 'Tweet to Unlock Download' button text?

The button text is filterable, which means you can override it's label by placing a small PHP snippet in your theme's function.php. You can use the follow code to change the button's text:

function dlm_tl_tweet_button_text( $text ) {
	return 'My custom button text';

add_filter( 'dlm_tl_download_button_label', 'dlm_tl_tweet_button_text' );

Was this article helpful? Yes · No