I am developing a custom WP plugin for a client and I wish to make sure that the client does not install it on any other domain other than the one specified. If the client tries to install the plugin on other domains, it should throw out an exception and plugin should get deactivated or self destruct.

How can I make this happen? What is the code for this and where do I add it?


2 Answers 2


You could use a combination of the file content and the domain to create a unique hash.


$md5 = md5( file_get_contents( __FILE__ ) . $_SERVER['HTTP_HOST'] );
if ( 'be5d38f32a5d4a897e6c878f0c2f1b14' !== $md5 )
    deactivate_plugins( plugin_basename( __FILE__ ) );

Additionally, you could check each week per remote request to your server, if the hash is registered for that domain.

But be aware, this can be changed very easily. There is just no way enforce a domain.


just check that $_SERVER['HTTP_HOST'] is matching the domain somewhere in the code. I think @toscho's answer just over complicates the check as honest people will not try to break a lock once they see it is in place and you can't protect against someone willing to spend the time/money to break your protection.

I am not a lawyer

be very careful with this kind of things. When people buy something they expect to use it in many ways (like being able to use the plugin after changing the domain), and if you limit it you better explicitly say it in your contract.

  • Yes not to worry, we have that covered. We are essentially selling a single domain license. Should the client want to upgrade to multiple licenses, we will do so.
    – Amjad
    Nov 26, 2013 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.