Add license validation to your WordPress plugin in just a few lines of code.
Your customers buy your plugin on your website (using Stripe), and KeyKit automatically creates a license key. Your plugin checks this key to verify the customer has a valid license.
function check_license($license_key, $site_url) { $response = wp_remote_post('https://keykit.app/api/validate', [ 'headers' => [ 'Content-Type' => 'application/json', 'x-org-id' => 'your-org-id', 'x-keykit-signature' => 'your-signature' ], 'body' => json_encode([ 'token' => $license_key, 'siteId' => $site_url ]) ]); if (is_wp_error($response)) { return false; } $body = wp_remote_retrieve_body($response); $data = json_decode($body, true); return $data['valid'] ?? false; }
// Check license when plugin loads add_action('init', function() { $license_key = get_option('my_plugin_license_key'); $site_url = home_url(); if (!check_license($license_key, $site_url)) { // Show license error or disable features add_action('admin_notices', function() { echo '<div class="notice notice-error"><p>Invalid license key. Please check your license.</p></div>'; }); } });
// Add license field to settings page add_action('admin_menu', function() { add_options_page( 'Plugin License', 'Plugin License', 'manage_options', 'plugin-license', function() { if (isset($_POST['license_key'])) { update_option('my_plugin_license_key', sanitize_text_field($_POST['license_key'])); echo '<div class="notice notice-success"><p>License key saved!</p></div>'; } $current_key = get_option('my_plugin_license_key', ''); echo '<form method="post">'; echo '<table class="form-table">'; echo '<tr><th>License Key</th><td><input type="text" name="license_key" value="' . esc_attr($current_key) . '" class="regular-text" /></td></tr>'; echo '</table>'; echo '<input type="submit" class="button-primary" value="Save License" />'; echo '</form>'; } ); });
Your WordPress plugin now validates licenses automatically. When customers buy your plugin, they'll get a license key that your plugin can verify.
If you need assistance with WordPress integration, check our documentation or contact support.