Display Country based Flags for cPanel last Login IP Address

Display Country based Flags for cPanel last Login IP Address

Here is how to detect user country from the IP address that cPanel displays on the right side of the Tools page, and add a flag representing that country.

Display Country based Flags  for cPanel last Login IP Address
Display Country based Flags for cPanel last Login IP Address

1.) First download the flag icons of all countries here: https://flagpedia.net/download/

Download flag icons of all countries
Download flag icons of all countries

Create a new directory “flags” under Jupiter theme and add all flags there /usr/local/cpanel/base/frontend/jupiter/flags


We are going to use a free API: https://github.com/hakanensari/country and you don’t need any API key.

2.) Create a new file /var/cpanel/customizations/content_includes/cpanel_jupiter_footer_after.html.tt and add the following javascript code to it:

Save the file and test, you should see flag icon appear immediately.


In the provided code we make sure to convert the country code from the API to lowercase letters in order to match filenames of the icons, and also check if API response was successful – if not, to avoid broken images, no icon will be shown.

Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.