Page MenuHomePhabricator

Parser function {{#userid}} to return a user's userID which can test whether a user exists
Open, Needs TriagePublicFeature

Description

There should be a parser function to test whether a user account exists.

  • {{#ifexist:User:Username}} only tests whether the userpage exists. Since userpages can exist independently of having an associated user, this doesn't work. A user may exist, but have a redlinked userpage. Or a userpage may exist for a user that doesn't.
  • {{GENDER:Username}} doesn't work either. If queried with a non-existent user, it returns its default (gender-neutral) value, rather than erroring out.

Use cases

  • Use case one: Many templates take a username, e.g. userlink templates like https://en.wikipedia.org/wiki/Template:User. Such templates could say if the user doesn't exist (for example due to a typo).
  • Use case two: Some users incorrectly think an account doesn't exist when a red user page says the page doesn't exist. For their own account, they think the account is broken. Red user pages display MediaWiki:Newarticletext which could be customized to say this user account exists but has not created an optional user page. If the account doesn't exist, then MediaWiki:Userpage-userdoesnotexist is displayed, but most users don't know that.

Notes

If there were a more general function to pull a user's userID based on their username, that would probably work better, such as {{#userID|username}} based on getId().

Event Timeline

Aklapper renamed this task from Feature request: Test whether user exists to Test whether a user exists.Oct 3 2023, 3:01 PM

I think you've got two different things here:

  1. Function to test whether a user exists {{#ifuserexists}}
  2. Change to {{GENDER}} to make it error out if the user doesn't exist, e.g. output “user does not exist.”

I don't see a reason why both shouldn't be implemented.

  • If #1 is fixed, then they could be nested {{#ifuserexists:username|{{GENDER:username}}|user does not exist}}, but that seems hackish.
  • If #2 is fixed, then using it to test if a user exists seems hackish, which makes #1 worthwhile.
Bugreporter2 renamed this task from Test whether a user exists to Parser function to {{#ifuserexists}} to test whether a user exists.Sep 26 2025, 11:54 AM
Bugreporter2 updated the task description. (Show Details)
Bugreporter2 renamed this task from Parser function to {{#ifuserexists}} to test whether a user exists to Parser function {{#userid}} to return a user's userID which can test whether a user exists.Sep 26 2025, 12:08 PM
Bugreporter2 updated the task description. (Show Details)