Skip to content

Github mirror of "mediawiki/extensions/UserProfile" - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)

Notifications You must be signed in to change notification settings

wikimedia/mediawiki-extensions-UserProfile

Repository files navigation

UserProfile

Developer info

Adding new fields

  • Using attribute (static) - UserProfileFields
"UserProfileFields": {
    "myfield": {
        "msgKey": "i18n-key-for-label",
        "formDefinition": {
            "type": "text",
            "required": true,
            "placeholder": "placeholder"
            "<<any other values for the Forms field definition>>": true
        },
        "isPublic": true,
        "rlModules": [ "special-rl-module-required-for-form-field" ]
    }   
}
  • Using config (static) - 'wgUserProfileFields'
$GLOBALS['wgUserProfileFields']['myfield'] = [
    'msgKey' => 'i18n-key-for-label',
    'formDefinition' => [
        'type' => 'text',
        'required' => true,
        'placeholder' => 'placeholder'
        // <<any other values for the Forms field definition>>
    ],
    'isPublic' => true, // If false, shown only to the user
    'rlModules' => [ 'special-rl-module-required-for-form-field' ]
];
  • Using service (dynamic) - UserProfile.FieldRegistry
$registry = MediaWikiServices::getInstance()->getService( 'UserProfile.FieldRegistry' );
$field = new \MediaWiki\Extension\UserProfile\Field\ProfileField( 'myField', 'i18n-key-for-label', true, [
    'type' => 'text',
    'required' => true,
    'placeholder' => 'placeholder'
], [ 'special-rl-module-required-for-form-field' ] );
// Will also override existing field with the same name
$registry->registerField( 'myField', $field );

Also, you can unregister a field by calling $registry->unregisterField( 'myField' ).

Logging

Channel UserProfile.Manager

About

Github mirror of "mediawiki/extensions/UserProfile" - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer_access for contributing)

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •