Search code examples
mediawikimediawiki-extensions

Mediawiki parser function/extension to check if a user exists?


Is there a Mediawiki extension or built-in wikitext function that checks if an account with a given name exists?

I'm looking for something like:

{{#ifuserexists: username|wikitext if account exists with that username|wikitext otherwise}}

There doesn't appear to be anything easy to find in that regard (search "mediawiki parser function if user exist" and "mediawiki check if user exists" on Google or Bing for example of how search engines utterly fail to find a relevant extension)


Solution

  • Found something that works.

    Contribution Scores provides a parser function {{#cscore: username}} that produces an activity score if the user in question exists and "Invalid username" if the user doesn't exist.

    https://www.mediawiki.org/wiki/Extension:Contribution_Scores

    Just a warning: #cscore produces a malformed/corrupted string object that is thoroughly incompatible with standard string processing parser functions (including #ifeq, #sub, #replace), so you can't make a template that implements conditionals based on this. All efforts to parse the output produced unexpected/wrong results or UNIQ-QINUs.

    If you merely need to view the created/uncreated status of user accounts via a manually configured dashboard, #cscore is sufficient. However, it doesn't work for any programmatic or automated mechanism in wikitext except if you use a nonstandard or deep wikitext manipulation extension where the standard StringFunctions, ParserFunctions, and RegexFunctions fall flat.