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: 54.156.39.245!



  Comment Form

Click here to open the 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.8
  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! Thanks!

Ads help me to help you! Thanks!