Extension:GlobalPreferences/API
Getting global preferences
editglobalpreferences | |
---|---|
Get global preferences and local overrides for the current user. This module cannot be used as a generator. | |
Prefix | gpr |
Required rights | editmyoptions |
Post only? | No |
Generated help | Current |
If only the effective preferences for a user are required, the usual meta=userinfo&uiprop=options
can be used, however if you need to know where is every preference value coming from, you will need to use this API.
Parameters
editgprprop
: Which preferences to get (Default:preferences|localoverrides
)preferences
: Global preferenceslocaloverrides
: Local overrides
Example
editResult |
---|
{
"batchcomplete": "",
"query": {
"globalpreferences": {
"preferences": {
"advancedsearch": "1",
"ccmeonemails": "1",
"disablemail": "0",
"email-allow-new-users": 1
},
"localoverrides": {
"ccmeonemails": 0,
"email-allow-new-users": 0
}
}
}
}
|
Possible errors
editNone.
Setting global preferences and local overrides
edit
| ||||||||||||
|
Token
editTo change options, a CSRF token is required.
Tokens can be obtained via action=query&meta=tokens
Result |
---|
{
"query": {
"tokens": {
"csrftoken": "f38d52ee5c9b49ce17f5e55c48bb1166547cbc71+\\"
}
}
}
|
Changing options
editGlobalPreferences provides two modules to change preferences, action=globalpreferences
and action=globalpreferenceoverrides
. They work exactly like action=options
and have the same parameters.
Parameters
editreset
: Resets all preferences.- Resetting a global preference means it will not be global anymore while resetting a local override means that the global preference will be used.
resetkinds
: List of types of preferences to reset when the reset parameter is set. (Default:all
)change
: Pipe-separated list of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters.
- Note: Providing only names of preferences without equal sign (e.g.
hideminor|skin
) results in resetting them.
optionname
: A name of a preference which should have an optionvalue set.optionvalue
: A value of the preference specified by the optionname, can contain pipe characters.token
: A "csrf" token retrieved fromaction=query&meta=tokens
The change parameter cannot be used to set a value which contains a pipe character "|", as it is used by the API to separate options. If you need to set such a value (for example, a user signature) use an optionname & optionvalue pair.
Example
editNote: In this example, all parameters are passed in a GET request for the sake of simplicity. However, changing preferences requires POST requests; GET requests will cause an error.
Result |
---|
{
"globalpreferences": "success"
}
|
Result |
---|
{
"globalpreferences": "success"
}
|
Result |
---|
{
"globalpreferenceoverrides": "success"
}
|
Possible errors
editIn addition to the usual stuff :
Code | Info |
---|---|
notloggedin | Anonymous users cannot change preferences |
nochanges | No changes were requested |