UserRestrictions by Teppo

Apply configured restrictions for users.

User Restrictions module for ProcessWire

This module provides additional restrictions for users. As of this writing it can be used to restrict login attempts to the admin using a predefined set of IPs or geolocations.

Note: geolocation data is fetched from an external API, which may require credentials. This feature has been built with ipgeolocation.io in mind, but should technically work with any other service as well — as long as said service returns data in JSON format.

Configuration settings are defined via $config->UserRestrictions:

$config->UserRestrictions = [
	'login_restriction_enabled' => !$this->config->debug,
	'login_restriction_enabled_for' => [
		// array containing users that are restricted; supported formats:
		// 'my_admin_username' or 'user:my_admin_user' (username)
		// 41 or 'user:41' (user ID)
		// 'role:superuser' (role)
		// 'regex:/.*/' (regex pattern, which is matched against username)
	],
	'valid_ip_addresses' => [
		// list of valid IP addresses; supported formats:
		// '127.0.0.1' (individual IP)
		// '127.0.0.1-127.0.0.255' (IP range)
		// '127.0.0.0/24' (CIDR)
	],
	'valid_geolocations' => [
		// list of valid geolocations; supported formats:
		// 'Finland' or 'country:Finland' (country)
		// 'prefix:value' (any other valid geolocation data key)
	],
	'geolocation_api_url' => 'https://api.ipgeolocation.io/v2/ipgeo?apiKey={api_key}&ip={ip}',
	'geolocation_api_key' => '',
	'display_errors' => false,
	'log_errors' => true,
];

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Latest news

  • ProcessWire Weekly #575
    The 575th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 17 May 2025
  • New ProcessWire admin redesign
    When you upgrade to ProcessWire 3.0.248 or newer (currently the dev branch), you’ll immediately notice something new and beautiful…
    Blog / 9 May 2025
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK