FREE WordPress myCustom asset for Unity now available on the Asset Store

in #gaming2 years ago

big.jpg

I've been selling products that bridge the gap between WordPress and Unity for a long time now. I made the entire process so simple it's not even funny. One of my biggest sellers consists of a WordPress plugin and a single script for Unity. Super useful, but a single script. The documentation is bigger than the script.

It is so simple, in fact, that I actually describe the 3 steps on my website for everyone to see. To start with, all my WordPress kits extend the WordPress Login kit so as a bare minimum you do need to have that. By having this it means you let the login kit take care of authenticating your users or creating new accounts etc. So now you come along and you want your own custom functionality...

What do you do?

  1. Copy paste one of my existing functions and change the "action" string to something you want. Let's say "CountMySiteUsers".
  2. Open up unity_functions.php and create a new function called loginCountMySiteUsers() and make it do whatever it is you want to do
  3. Use your new function...

That simple... I wasn't kidding when I said I made it easy to use...

What do I do for you?

  • I make sure the call came from your game and not some hacker with a web browser
  • I secure the text that comes in to make sure ONLY your game can access your database
  • I find the relevant user for you so you can just get started using $current_user and not have to worry about who is who
  • I make sure the person calling your code is logged in
  • I provide you with a simple PrintError($message) function to tell Unity if and when something went wrong during the execution of your code
  • I provide you with a SendNode () and SendField() function to use to send back your data in CML format (XML on steroids, basically)
  • I provide you with Posted(), Postedi() and Postedf() functions to fetch your GET and POST data without having to worry about errors relating to trying to fetch fields that were not sent and thus trying to use NULL values
  • If you make use of the included PrintError() and SendToUnity() functions in WordPress then I offer you a simple method of implementing error handling in Unity.

Example:

WUCustom.GetMySiteUsers(SaveTheResult, errorResponse:GenerateErrorReport);

Simply specify what function to run when SendToUnity was used and which function to run when PrintError was used. That simple.

All of that you get out of the box so all you have to do is add that single function that does your custom logic and I take care of all the rest.

Sounds too good to be true. What's the catch?

  1. People simply don't read the instructions and then keep asking me how to do it
  2. Every time I release an update it overwrites the old files and deletes all your custom functions in the process

Enter WordPress myCustom

The solution to this problem is to release a product that meets the following conditions:

  1. It must be a bare bones product that does only the absolute minimum to get everything up and running. You must not be left scratching your head asking "What is going on?".
  2. Place this code in a separate plugin from all my others so that my future updates don't affect your code
  3. Never update this plugin after it's release (otherwise what was the point?)

This was the goal with WordPress myCustom. For the bare bones system I created only 1 function that simply returns a true or false result. It asks the question: Does this person have an active subscription? In order to get an answer to this question I demonstrated the other thing people keep asking me after buying the WordPress Money asset: "How can I sell X via WooCommerce and then use that item in Unity?"

Again, I explain the steps in the product documentation but since it is as simple as:

  1. taking an existing product and modifying the SKU so my kit picks it up
  2. create a custom function to handle product purchases of that type
  3. register to my custom action so your function gets called
    ...I figured showing them how to write the one line of code to create the hook and then write the one function that parses the WooCommerce transaction into a subscription system so they can see it in action would be a nice touch.

As such, WordPress myCustom can be downloaded, for free, right now either on my itch.io page or from the Asset Store and as part of the kit you are shown how to create your own custom actions by me implementing a WooCommerce based subscription system for Unity. Simply go to the site and click on the daily, weekly or monthly product (as defined by the SKU), enter a qty and then pay... just like any WooCommerce transaction. If you have my WordPress Money asset installed then it will pick up on the transaction and add the relevant number of days, weeks or months (taking into account the quantity you purchased) and add that to your account. Now that function that checks if you have an active subscription can check your account and simply return whether or not today is past your account expiration date. Job done.

Quick recap

  1. WordPress myCustom is completely free to download and use
  2. WordPress myCustom extends WordPress Login so it does require that you have that asset
  3. The sample project shows you how to create custom actions AND how to integrate WooCommerce into Unity projects. If you are interested in that functionality then you will also need to get WordPress Money. If you don't care about that then you are good to go without it.

Download WordPress myCustom HERE

Enjoy!