License keys for a WordPress plugin: how to set them up
To add license keys to a WordPress plugin, attach a License keys benefit to your Ruba product, let the buyer paste the key in your plugin’s settings, and have the plugin call Ruba’s validate endpoint with the key and your organization ID. Ruba issues the keys and hosts the check, and pays you to your own bank with no company needed.
What a key does for a plugin
Each Ruba key can limit activations from 1 to 50 and expire on a date, which suits a plugin sold per site. Sameer in Rawalpindi sells a booking-form plugin. The free version has three forms. The paid version has unlimited forms. A buyer pays on Ruba’s checkout, gets a key, and pastes it into the plugin’s settings page. The plugin then asks Ruba: is this key valid for my shop, and is it allowed on this site?
This page is the technical side. For the business side, see our guide on selling WordPress plugins and themes.
The life of a key on one site
- BuyBuyer paysOn a Ruba checkout.
- PasteKey in settingsOn the WordPress admin page.
- ActivateRegister the siteLabel it with the site address.
- CheckValidateOn a schedule or before paid features.
Validate from PHP
WordPress has its own HTTP functions, so you do not need a library. Call Ruba’s validate endpoint with the key, your organization ID and, if you use one, the activation ID. Treat any error or non-success answer as “not valid”.
<?php
function myplugin_validate_license( string $key, string $activation_id ): bool {
$response = wp_remote_post(
'https://api.getruba.com/v1/customer-portal/license-keys/validate',
array(
'timeout' => 15,
'headers' => array( 'Content-Type' => 'application/json' ),
'body' => wp_json_encode(
array(
'key' => $key,
'organization_id' => MYPLUGIN_RUBA_ORG_ID,
'activation_id' => $activation_id,
)
),
)
);
if ( is_wp_error( $response ) ) {
return false;
}
return wp_remote_retrieve_response_code( $response ) < 300;
}Always send your organization ID, so a valid key from another seller’s shop cannot unlock your plugin. Call this on a schedule, and cache the result, rather than on every page load.
A Ruba checkout link needs no website: one reusable link in your bio or post opens a fresh checkout for every visit.
Choose the key rules
Great for Plugins you keep improving.
Watch for Be clear what a buyer keeps after a year.
Great for Small plugins that rarely change.
Watch for You support old versions for years.
What to do next
See the early-access deal. Ruba charges 4% + $0.50 per sale with no monthly fee and pays you in PKR, INR or BDT to your own bank. Read selling WordPress plugins and themes.
Check the key on activation and on update. Begin as an individual: no company, no monthly fee. Once approved in early access, 4% + $0.50 per sale is locked in for your WordPress plugin licence while your account is open and in good standing. Should a fee ever show up that Ruba never told you about, Ruba refunds it and pays you $100. Terms apply. See the early-access deal.
Questions people ask
How does a WordPress plugin check a key with Ruba?
It makes an HTTP request to Ruba’s validate endpoint with the key and your organization ID, using WordPress’s own HTTP functions. If the check succeeds, the plugin unlocks its paid features. Ruba hosts the validation.
How do I limit a key to a few sites?
Set an activation limit on the License keys benefit, from 1 to 50. Create an activation with a label, such as the site address, when the plugin is activated on a site, and send the activation ID when you validate.
Can a key expire when a yearly plan ends?
Yes. A key can expire after a number of days, months or years. It can be revoked automatically when the subscription that supplied it ends.
Does Ruba host plugin updates?
Ruba has license keys and file downloads. Hosting update packages and an update server for WordPress is something you build yourself or with other tools.
Is this different from selling a plugin?
This page is the technical side. For the business side, read our guide on selling WordPress plugins and themes from Pakistan.
Sources
We check these when we update this guide. Rules can change, so check them yourself before you decide.
- Ruba: license keysChecked 26 Nov 2026
- Ruba: file downloadsChecked 26 Nov 2026
- Ruba: subscriptionsChecked 26 Nov 2026
- Ruba: pricing and feesChecked 26 Nov 2026