Category Archives: Coding

All about coding

[SOLVED] Unbounce – Populate Drop Down(s) with URL Parameter Data

Unbounce is a great landing page creation tool but in some areas it lacks those “extra” little features desperately needed to make the end user experience comfortable and as we know, comfort leads to conversions!

For example, I wanted to create a PPC campaign so that when the user clicks on an ad, I needed certain drop downs on the landing page to be pre-populated with values passed from the url string so the user does not have to select them manually.

I checked A LOT of posts on the unbounce forum (as recommended by Unbounce technical support) , none of them really worked that well and in most cases were overly complicated, so in the end after some google searches I found a simple, working solution.

Here is the code below I used in the end to populate the drop down menus with url parameters from the query.

I tested this on 19th of October 2019 in Chrome 77.0.3865.120 on Mac and works great.


First, make sure the names of your fields match the names of the fields specified in your script. In the case below, the field is called location. You could use a different name but make sure the names in the url, script and form are the same.

Second, don’t forget to put your code in the <head> part of the landing page so that it loads before the fields on the landing page.


How to Show a Different WordPress Theme based on IP Address [SOLVED]

A colleague and I recently stumbled on a situation where we had to show one wordpress theme to the web site visitors but show a different theme to ourselves so we can develop the new theme on the live site but not showing the development theme to the web site visitors.

A search on uncle google did not yield any decent results and we did not want a bloaty third party plugin slowing things down and in the end we figured that the best way will be to filter our ip’s and switch the theme based on ip address.

So we spun up a quick, plugin and used the switch_theme function in wordpress.

BOOM! Now when we visit the clients site I can see the new theme and see how it interacts with the current content without interrupting the user experience. NICE!

Here is the code below which help us accomplish the task.

All you have to do is:

  1. Create a file inside your plugins folder called “change-the-theme.php”
  2. Drop the code below into that file
  3. Add the ip addresses to the list of developers ip’s
  4. Change the theme names


[SOLVED] WooCommerce conditional fields for gifts options on checkout

Built a web site recently using WooCommerce and decided that a gift wrapping option would be wonderful idea when user checks out.

However, the WooCommerce Checkout Add-Ons plugin whilst its great, is still in its infancy and on the checkout page, it simply populates the page with all the add ons, so makes the checkout page look HUGE!

My idea, was to add a checkbox asking the user if they wanted to gift wrap the order and then when checked, a list of the options would appear.


[SOLVED] MAMP – allowing clients to view dev sites on your local machine (with dynamic ip)

As a web developer, I like to work on web sites on my local machine and then give clients a link to the site which is hosted on my local machine so they can view progress. This save me A LOT of time syncing with remote servers as the client can view the dev site in real time on my computer.

The link I give to the client looks something like this: so essentially its not any weird hostname, its a very familiar and easy to remember link as it will contain their domain name.

Below you will find the steps necessary to make this magic happen.

Checklist before you start

There are a few essential pieces of stuff you need before you start setting things up.

  1. You need to know the ip of your local machine on your current local network (usually its something like 192.168.1.x). You should be able to find this in your network settings on your computer (for step 3).
  2. You need to have a “DynDNS Pro and Host Services” account, which costs $40 a year (WELL WORTH IT if you have more than one dev site).
  3. You need to have your site configured inside of MAMP like (see step 2).
  4. You need to have admin access to your router in order to add a NAT rule (for step 4).

Why use offer a great little utility tool for mac and windows so that if your ip changes, then your dynamic dns hostname also gets updated automatically so you don’t need to keep logging into to update your ip.

See: <—get this (very useful)

OKAY! Lets go!

Step 1

Make sure your MAMP ports are configured to port 80.

Step 2

Make sure your MAMP site has a proper dns domain name.

Step 3

Create a DNS alias over at and make a note of the new hostname you create as you will need to create a cname record with the alias on the clients domain name.

For the sake of our exercise the host name at is:

IMPORTANT: make a note of the new hostname as you will need it for the CNAME records on your clients domain DNS.

Step 4

Create a sub domain on your client’s dns with the hostname you created at


Update your router so that external requests to the devsites domain are routed to your computer.

This part can be a little daunting for some as you have to dig into the advanced settings of your router.

I have a router given to me by my Spanish ISP, your might differ but for the most part a lot of the navigation will be similar.

Just make sure that you are looking for NAT and make sure you have your local IP to hand.

In Conclusion

As long as you have followed each step carefully, if your clients browses to the dev domain you have created, then they will see the development version of their web site running on your local machine.

Obviously, it goes without saying that you need to have MAMP running in order for them to view the site and your computer is connected to the internet.

[SOLVED] How to remove 2FA from WHMCS Login Page

WHMCS is great, for the most part, but last night I tried to login to my WHMCS admin panel with my google two factor auth only to be met with an error saying my 2fa code was incorrect.

I even tried using the backup code and still met with an error.

I raised a ticket with WHMCS 12 hours ago, no response yet. GRRRRR!

If you have access to the WHMCS database through phpmyadmin or similar then find the table called: tbladmins.

Then find the column called “authmodule”.

Clear whatever is in that field (mine said “totp”).

You will then be able to access WHCMS admin without using 2fa.

[Solved] Get Array of Terms for Custom Post Type Outside of Loop with Post ID

Every stone I overturned looking for the answer to this issue I was met with “use wp_get_post_terms()” but unfortunately it does not work on custom post types.

The solution, after much digging and experimenting is to use get_the_term_list() but with a couple of twists.

Now, I have a custom post type called “faq”.

To get the “terms” or “tags” for the “faq” post type you need to know what the “taxonomy name” is. In this case, the taxonomy name is “faqs-tags”.

To find out the taxonomy name for the custom post type, check the screenshot below. Easy!

[SOLVED] Get ENOM balance into WHMCS

I have been running WHMCS for a while now and have had to keep logging into ENOM to get my balance which is a hassle as I have two factor auth and security questions setup so takes me a minute to get through all of that.

Here is some php script you can put in a WHMCS widget to display your enom balance in your admin dashboard saving you some time.

We are using simplexml to parse the results.

Result will be something like this.


[Solved] CSF/LFD Stop Emails containing “Suspicious process running under use X”

CSF really is an excellent IP Tables wrapper but these alerts can become a burden and you can essentially receive hundreds of them per day. Okay, for sure, the goal should be to fix the issues first but if you are a busy server admin, then this can take time so if you need to disable the emails, then just follow the steps below.

1. Edit the CSF config file

2. Search for the following settings PT_USERMEM and PT_USERTIME and set them both to 0.

3. Restart CSf and LFD

The warning emails should stop coming now.

[SOLVED] – WHM Cpanel on Amazon EC2 Servers + FTP TLS Dreamweaver Issue

One of my customers has an Amazon EC2 instance with WHM installed. A decision was made recently to close off port 21 and force FTP over TLS for better security during ftp sessions.

However, one of the team was saying they could not get Dreamweaver to connect  and was getting an error when trying to connect with TLS. All his settings seemed fine and in fact I also was able to replicate his issue on my local copy of Dreamweaver CC 2016 so I turned my attention to the web server on Amazon.

After ALOT of searching about, I found that, if we want to force FTP over TLS on an Amazon EC2 instance, I  had to make a change to the /etc/pure-ftpd.conf file by adding the main server ip to the ForcePassiveIP setting. The reason for this is that EC2 instances use NAT routing and dynamic IP’s and you need to provide a fixed IP so that the passive mode can send the return response back down the correct route, otherwise it does not know where to go.

Here is the changes I had to make.

Side Note: If you are forcing TLS, then make sure that you have already configured your PassivePortRange inside the /etc/pure-ftpd.conf file and also allowed the ports to be open on your firewall. Here is another post giving some details on how to do that.

STEP 1: Open up the FTP config file.

STEP 2: Add your server IP to the ForcePassiveIP setting. This will be the main Public IP of your server.

STEP 3: Restart FTP server

After that, TLS on Dreamweaver was working perfectly.


Using CURL with PHP to send POST field data using http header Authentication

Okay, so until now I had been using api keys passed through the post fields but on a more recent project I was asked to send the api key through the headers when making the request, so I have made myself a little function to use curl and pass the api key through CURLOPT_HTTPHEADER.

This will be the call to your curl function and you can print out the results of the call.