Manual:Hooks/GetUserBlock

From MediaWiki.org
Jump to navigation Jump to search
GetUserBlock
Available from version 1.34.0 (Gerrit change 525305)
Modify the block found by the block manager.
Define function:
public static function onGetUserBlock( User $user, $ip, MediaWiki\Block\AbstractBlock &$block ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"GetUserBlock": "MyExtensionHooks::onGetUserBlock"
	}
}

For MediaWiki ≤1.25:

$wgHooks['GetUserBlock'][] = 'MyExtensionHooks::onGetUserBlock';
Called from:File(s): block/BlockManager.php
Function(s): getUserBlock

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

The block may be a single block or a composite block made from multiple blocks; the original blocks can be seen using MediaWiki\Block\CompositeBlock::getOriginalBlocks()

Details[edit]

  • $user: User object
  • $ip: IP address of user
  • &$block: MediaWiki\Block\AbstractBlock object