Can I set "Create Virtual Server" to default to "Custom Username" (instead of Automatic)

When I click “Create Virtual Server” the default radio button is selected on “Automatic”. Is there a way I can have that automatically be set to “Custom username” instead? (I have never not used a custom username.)

Thanks in advance for any advice.

RJD

Operating system Ubuntu Linux 20.04.2
Webmin version 1.973
Usermin version 1.823
Virtualmin version 6.16
Authentic theme version 19.73

Hello @Ron_E_James_D.O and welcome to the community.

Sorry, I worded that poorly. I meant to ask if it can automatically be selected on that radio button (a minor annoyance to be sure, but I have literally never not clicked it on creating a virtual server).

No, the fault is mine - I should have read the topic of the message carefully. You were clear that you would like “Custom Username” radio button to be selected by default.

My answer is that I am not aware of any configuration option which will let you do that - though I could be wrong about this. If so, someone in the community will correct me shortly. It is, however, possible to use JavaScript to do what you want - the selector concerned is:

#hiddendiv_basic > table > tbody > tr:nth-child(9) > td.col_value > span:nth-child(2) > label

Or else the theme could be edited directly - it should be a very minor edit, I imagine, to set the ‘checked’ property to the other HTML input element.

If you could wait a bit, I will look into this when I get to my desktop.

Theme should not be edited directly manually! :slightly_smiling_face:

Is there a way I can have that automatically be set to “Custom username” field instead?

There are Theme Extensions which could be used to run custom codes, which survive updates.

This is how it could be done:


Code snippet:

$(document).on(vars.h.event.page.end, function() {
    const cn = function() {
        let df = document.querySelector('[data-uri*="virtual-server/domain_form.cgi"]');
        if (df) {
            let def = df.querySelector('input[name="vuser_def"][value="0"]');
            let dom = df.querySelector('input[name="dom"]');
            if (def) {
                def.click();
                dom.focus();
            }
        }
    }
    setTimeout(cn);
});

Wow @Ilia, this is so cool and can be used in so many ways to customize the Virtualmin UI.

There you go, @Ron_E_James_D.O. Illia has provided the solution that you wanted.

Nice, awesome, thanks guys, I did not even know that was there.

RJD

Yeah, thanks. The problem is that it is not that simple for a regular user or any user who is not familiar with how things work. But I am ready to assist thought. :slightly_smiling_face:

1 Like