Manual:Hooks/BlockIp

BlockIp
Available from version 1.4.0
Occurs whenever the software receives a request to block an IP address or user
Define function:
public static function onBlockIp( &$block, &$user, &$reason ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"BlockIp": "MediaWiki\\Extension\\MyExtension\\Hooks::onBlockIp"
	}
}
Called from: File(s): specials/SpecialBlock.php
Interface: BlockIpHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:BlockIp extensions.


Details edit

This occurs before an IP address or user is blocked, or the block settings are changed.

  • $block: the Block object about to be saved
  • $user: the user doing the block (not the one being blocked)
  • &$reason: if the hook is aborted, the error message in an array, by default: array( 'hookaborted' ) (since 1.23, gerrit:108285)

See also edit