Manual:Hooks/UserCanSendEmail

From MediaWiki.org
Jump to navigation Jump to search
UserCanSendEmail
Available from version 1.12.0
To override User::canSendEmail() permission check
Define function:
public static function onUserCanSendEmail( $user, &$canSend ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserCanSendEmail": "MyExtensionHooks::onUserCanSendEmail"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserCanSendEmail'][] = 'MyExtensionHooks::onUserCanSendEmail';
Called from: File(s): User.php

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

Details[edit]

  • $user: User (object) whose permission is being checked
  • &$canSend: bool set on input, can override on output

By default, users can send email if email sending is enabled, they have the sendemail right, and they pass an email confirmed check.

See also[edit]