Manual:Hooks/BlockIp

From Linux Web Expert

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

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:BlockIp extensions</tvar>.</translate>


Details

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