Manual:Hooks/ArticleProtect

From MediaWiki.org
Jump to navigation Jump to search
ArticleProtect
Available from version 1.4.0
Occurs whenever the software receives a request to protect an article
Define function:
public static function onArticleProtect( &$wikiPage, &$user, $protect, $reason, $moveonly ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ArticleProtect": "MyExtensionHooks::onArticleProtect"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ArticleProtect'][] = 'MyExtensionHooks::onArticleProtect';
Called from:File(s): page/WikiPage.php

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

Details[edit]

  • $wikiPage: (object) the wikipage being protected
  • $user: (object) the user doing the protection
  • $protect*: boolean flag indicating whether the request is protect or unprotect
  • $reason: (string) Reason for protect
  • $moveonly: (boolean) flag indicating whether this is for move only or not

See also[edit]