Manual:Hooks/ChangeTagCanCreate

From MediaWiki.org
Jump to navigation Jump to search
ChangeTagCanCreate
Available from version 1.25.0
Tell whether a change tag should be able to be created by users.
Define function:
public static function onChangeTagCanCreate( $tag, $user, Status &$status ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ChangeTagCanCreate": "MyExtensionHooks::onChangeTagCanCreate"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ChangeTagCanCreate'][] = 'MyExtensionHooks::onChangeTagCanCreate';
Called from:File(s): ChangeTags.php

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

Details[edit]

  • $tag: Name of the tag.
  • $user: User object representing the user who initiated the action. May be null.
  • &$status: Status object. Add your errors using $status->fatal() or warnings using $status->warning(). Errors and warnings will be relayed to the user. If you set an error, the user will be unable to create the tag.

Notes[edit]

This hook allows extensions to determine whether a change tag should be able to be created from the UI (Special:Tags) or via the API.

By default, users may create any tag, except if it contains invalid characters, it matches an existing tag name, or if the operation is prevented by this hook.

You could use this hook if you want to reserve a specific "namespace" of tags, or something similar. For example, the OAuth extension uses this hook to reserve all tags beginning with OAuth CID: (see source).

See also[edit]