Check License in Plugin Updates
I want to warn you – this tutorial is not for beginners 😈. Besides, you’d better read about creating a custom plugin update server at first.
Step 1. Pass a License Key to info.json
Make the replacements in the code here on line 20 and here on line 9.
$remote = wp_remote_get(
add_query_arg(
array(
'license_key' => urlencode( get_option( 'some_license_key' ) )
),
'https://rudrastyh.com/wp-content/uploads/updater/info.php'
),
array(
'timeout' => 10,
'headers' => array(
'Accept' => 'application/json'
)
)
);
If it is not 100% clear for you, let me describe. All we need to do is to pass an additional GET parameter to a json file URL, like this: info.php?license_key={KEY}
.
But the proper way to do it is:
- Use
get_option()
to get the license key value from settings. If you have troubles adding the settings page to your website admin area, I recommend to take a look at this plugin. - Use
add_query_arg()
to add the GET parameter to the json URL. - It is better to use
urlencode()
too if your plugin license keys contain non-URL characters.
Step 2. Make your info.json a PHP file!
I hope it doesn’t sound crazy for you, 🙃 maybe you didn’t know that but a PHP file can return any file type you want if you pass Content-Type
parameter to it. So, let’s create the info.php
file and don’t forget to make the replacements in the previous step.
$update = array();
...
// here we generate our JSON response
...
// no update is available by default
$update[ 'download_url' ] = '';
if( ! empty( $_GET['license_key' ] ) && license_check_logic( $_GET[ 'license_key' ] ) {
$update[ 'download_url' ] = 'pass the URL to plugin ZIP archive here';
}
...
header( 'Content-Type: application/json' );
echo json_encode( $update );
license_check_logic()
is just your custom function that checks if a license key is valid or not and return true or false accordingly.
And here is the WordPress magic – if you would like to disable plugin updates but leave the update notice, all you need to do is to pass the empty download_url
parameter in your info.json
(I mean info.php
).
This is how it will look in admin area:

Everything seems OK on the screenshot except one thing – we didn’t provide enough information for plugin users, how to renew. Let’s do it in the next step!
Step 3. Add some info at the end of your plugin update notice
Every time I work with WordPress, I understand how much I love it ❤️ – it allows to do so awesome things with just a small amount of code. And the below one will add our custom message at the end of WordPress default update message.
add_action( 'in_plugin_update_message-YOUR-PLUGIN/YOUR-PLUGIN.php', 'misha_update_message', 10, 2 );
function misha_update_message( $plugin_info_array, $plugin_info_object ) {
if( empty( $plugin_info_array[ 'package' ] ) ) {
echo ' Please renew your license to update. You can change your license key in Settings > General';
}
}
The result:

If you would like me to publish a specific tutorial, just let me know.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Please do a more in-depth tutorial haha. I’m intermediate and this went pretty fast. Even this one went pretty fast: https://rudrastyh.com/wordpress/self-hosted-plugin-update.html
Hi Chris,
Ok, I will record a video maybe.
That would be sick! You’re fast on the reply btw.
I’m implementing this now. I’d love to know how you generate all your JSON in Step 2 and other steps that you’ve maybe left out :)
Thank you rudrastyh! Can you create a new tutorial for check licence key for the using plugin? Thanks in advance.
Let me know when the video is out
Thanks Misha. I gotta say, I’m really loving your tutorial/guide style. I just wrapped up your Plugin updates guide and then this license guide.
Might be worth making a Udemy video series; Perhaps start with a “WordPress Plugins A-Z” guide. I could see a lot of people being interested in it.
Hi Shawn,
Thank you! And thanks for the idea to create a course.
Maybe one day… At this moment there are so much things in my to do list 🙃