API:User group membership
|Language:||English • Deutsch • 日本語|
Token[edit | edit source]
To change a user's group membership, a user rights token is required. This token is not equal to the edit token: it depends on the name of the user whose rights are being changed. A user rights token can be obtained as follows: Obtaining a user rights token
<?xml version="1.0"?> <api> <query> <users> <userid=2793024/> <name="Bob"/> </users> <tokens> <userrightstoken="f3c936c4ff8ee338a54e3a703ebafe3555aeb296+\\"/> </tokens> </query> </api>
Adding users to and removing them from groups[edit | edit source]
This module cannot be used as a Generator.
Users can be added to groups or removed from them with action=userrights.
Parameters[edit | edit source]
user: The name of the user whose rights you want to change.
token: The token obtained in the previous request. Take care to urlencode the '+' as '%2B'.
add: A pipe-separated list of groups you want to add the user to. Groups you're not allowed to add and groups the user is already in will be silently ignored
remove: A pipe-separated list of groups you want to remove the user from. Groups you're not allowed to remove and groups the users isn't in will be silently ignored
reason: Reason for the change (optional).
Sample request[edit | edit source]
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=userrights requires POST requests; GET requests will cause an error.
Removing Bob from the bureaucrat group, and adding him to the sysop and bot groups
<?xml version="1.0" encoding="utf-8"?> <api> <userrights user="Bob"> <removed> <group>bureaucrat</group> </removed> <added> <group>sysop</group> <group>bot</group> </add> </userrights> </api>
NOTE: If you don't have permission to add/remove users to/from groups, you'll get a result with empty
<added /> and
<removed /> tags rather than an error message, because all the groups you specified were silently ignored.
Possible errors[edit | edit source]
All errors are formatted as:
<error code="code" info="info">
|nouser||The user parameter must be set|
|nosuchuser||User "user" doesn't exist
Note: This may happen when trying to change an anonymous user's rights.
|notoken||The token parameter must be set|
|readonly||The wiki is in read-only mode
Note: In read-only mode, absolutely nothing can be changed.