How to configure and setup WHMCS Licensing addon
UPDATE: Please see my updated guide at http://markustenghamn.com/configure-setup-whmcs-licensing-addon
To follow this tutorial you will need a whmcs license and the whmcs licensing addon which can be found at the WHMCS website. I have tried to include as little code as possible in this tutorial, thus I will be referencing lines of code in the files you received when you downloaded the addon initially.
I will assume that anyone reading this post was able to upload the files included in the addon to the correct folders in your whmcs directory and that the addon shows up in your admin area. This tutorial is for those who are not very good with php and need some help adding this licensing script to the template, design, script or whatever you have made or just want to add a license to. I just got everything to work for me in a little less than an hour and I would say the whmcs instructions are not very clear on the procedure.
Lets get the basics out of the way, first step is to copy all the code in the check_sample_code.php file into the file you want protected by the licensing script. I was testing this out on a wordpress script so I used the admin login page to experiment, a good place to put the code would also be the index page of your project.
Once that is done we simply need to follow the instructions in the file, just edit line 17 to your whmcs root url, line 18 to anything you want, i put markspixel84209 to represent my website. No need to edit any other variables for now.
After that I went ahead and created a configuration.php file which the user can edit with his or her unique license key. This is what my configuration file looked like
/** Please replace the word key with the license key provided to you during the order process at Markspixel.com. */
$license_key=”key”;
This seemed more secure for me and easier for the client so that he or she doesn’t have to scroll through tons of code to activate their license.
I then went back to my code, the code we pasted into our index file, and scrolled to line 133 and simply replaced the sample key with my variable I just created in the configuration file “$license_key”. Now we should have the script working, if you go to the index page it should give you some kind of feedback of whether the license is working or not. Try issuing yourself a license in your whmcs script and put it into your configuration file and test to make sure everything works. You should see a fairly large output confirming your script is active, also check your whmcs to make sure it pops up as a valid license there as well. If not please go back and make sure you did all the steps correctly.
Next, now we need to get rid of the ugly textarea we see at the top and make the actual licensing stuff work the way we want it to. So I went to line 149 and put a # right infront of the “echo” this will comment the line and prevent the box from appearing. Delete line 152 to 156, line 152 to 156 should now be blank. If your project is php you can skip this step, however if you have html please add a
echo=”
on line 152 and then at the bottom of all of your html add a
“;
This will display all your html code if the license is active. If you use PHP you don’t need the echo tags in this step since the php should show up automatically. Now to make it work Cut lines 157 to 165 and paste them at the very bottom of the script.
Now your script should work, the page will be blank if the license is invalid, suspended or expired.
To tell whoever is using the script why they are getting a blank page simply edit the following comments
# Show Invalid Message
# Show Invalid Message
# Show Suspended Message
Please remember to use echo tags if you want to display text or html. Below is what I used to replace the comments.
echo “License Invalid, please enter your license key in the configuration.php file or contact Markspixel.com for support”;
echo “License Expired, please contact Markspixel.com”;
echo “License Suspended, please contact Markspixel.com”;
I hope that helps, If you have any questions or need any help feel free to contact me. If you have any helpful additions to this tutorial please make a comment or contact me.
Update: I forgot to show this in the tutorial, but to include the configuration file you need to have the following at the top of your index page before the licensing code begins.
include(“configuration.php”);
Of course please replace configuration.php with the name of your config file.
Also there is actually no need to add a echo=” on line 152 as described above. You could simply end the php code using ?> right after the { and then proceed to write all of your html code and then at the end before the } you could start php again using <?php this would probably be the better way of doing it.
can you please email me this or post on WHMCS forums with pictures, because your numbers lines got me lost and mine is just not working correctly.
I am sorry but I am unable to disclose any of the source according to the WHMCS team otherwise I would be happy to. Good luck!