How add more options to "Manage Users" section

Hey All,

I want to add more options to the “Gender” drop down menu within the “Manage Users” section. Is there a tutorial or guide that I can use?

It seems that this list is hard-coded:

Maybe you can add some JS code in a plugin that overrides “MODx.combo.Gender” with Ext.override, but I haven’t tested it.

Or maybe you can use an extra like ClassExtender to add a custom field to the user.

ClassExtender will add fields to the Create/Edit User panel in the Manager and store them in a custom table in the DB, but you could also borrow some of its code to do it yourself.

Here is some example plugin code (based on an older forum topic) that may or may not work to add more options to the combobox:

<?php
if ($modx->event->name === 'OnManagerPageBeforeRender') {
    $controller->addHtml('<script>
        Ext.onReady(function() {
            if (MODx.combo.Gender) {
                Ext.override(MODx.combo.Gender, {
                    listeners: {
                        afterRender: {
                            fn: function(elem) {
                                var store = elem.getStore();
                                // Add your custom data
                                var newData = [
                                    new Ext.data.Record({
                                        d: "Some value"
                                        ,v: "4"
                                    })
                                    ,new Ext.data.Record({
                                        d: "Some other value"
                                        ,v: "5"
                                    })
                                ];
                                store.add(newData);
                            }
                            ,scope: this
                        }
                    }
                });
            }
        });
    </script>');
}
2 Likes

This works. Thanks for the assist.

1 Like