Manual:Hooks/BlockIp

From MediaWiki.org
Jump to navigation Jump to search
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": "MyExtensionHooks::onBlockIp"
	}
}

For MediaWiki ≤1.25:

$wgHooks['BlockIp'][] = 'MyExtensionHooks::onBlockIp';
Called from:File(s): specials/SpecialBlock.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]