MENU

Hide forms for certain IP addresses

  Previous article Next article  

Hide website forms for certain IP addresses (partial banning)

Create a new User Defined Tag, named "form_ip_filter"

$banned_IPs = array(
  "123.123.000.000",
  "127.0.0.1"
);

$smarty->assign('ipbanned', '');

if(in_array($_SERVER['REMOTE_ADDR'], $banned_IPs)) $smarty->assign('ipbanned', 'true');

Fill the UDT with the IP addresses of the people you don't want to show the forms.

  How to use

Hide contact form
{form_ip_filter}

{if empty($ipbanned)}
  {FormBuilder form='contact'}
{/if}
Hide guestbook form, but show recieved messages
{form_ip_filter}

{if empty($ipbanned)}
  {Gbook action='form'}
{/if}

{Gbook}

  Working example

You wonder if it works? Add your own IP address in the list of addresses: 3.227.233.6!


Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!


  Comment Form






Note: your IP address will be stored on submit. I reserve the right to change or delete your response without notice! In case of abuse your IP address will be blocked!

GDPR privacy disclaimer
This form will send me your email address and your IP address.
If you don't want that, don't use this form!


  8 Comments

CMS Made Simple - Tutorials, tips and tricks - CMSMS

Hide forms for certain IP addresses

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.10
  Last updated: 07-06-2018
  Comments: 8
  http://cms.ms/LBxX

Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!

Ads help me to help you! Thanks!