<?php
$eventName = $modx->event->name;
switch($eventName) {
case'OnUserFormPrerender':
/* nothing */
break;
case'OnUserFormRender':
$modx->regClientStartupScript('/manager/defaults-for-user.js');
break;
}
return;function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload =
function()
{
if (oldonload)
{
oldonload();
}
func();
}
}
}
addLoadEvent(
function()
{
var myForm = document.forms[0]; // getElementById('ext-gen75'); //ext-gen76
// set defaults
var mySpecifyPasswordRadio = document.getElementById('modx-user-password-genmethod-s');
mySpecifyPasswordRadio.checked = 'checked';
var myCountryField = document.getElementById('modx-user-country');
myCountryField.value = 'United States';
var myCountryField = myForm.elements['country'];
myCountryField.value = 'United States';
var myActiveBox = document.getElementById('modx-user-active');
myActiveBox.checked = true;
// hide other fields
}
);
function changeForm()
{
var myForm = document.forms[0]; // getElementById('ext-gen75'); //ext-gen76
// set defaults
var mySpecifyPasswordRadio = document.getElementById('modx-user-password-genmethod-s');
mySpecifyPasswordRadio.checked = 'checked';
var myCountryField = document.getElementById('modx-user-country');
myCountryField.value = 'United States';
var myCountryField = myForm.elements['country'];
myCountryField.value = 'United States';
var myActiveBox = document.getElementById('modx-user-active');
myActiveBox.checked = true;
// hide other fields
}
setTimeout("changeForm()",1250);

<?php
$eventName = $modx->event->name;
switch($eventName) {
case'OnUserFormPrerender':
/* nothing */
break;
case'OnUserFormRender':
if($my_mode == modSystemEvent::MODE_NEW)
{
$modx->regClientStartupScript('/manager/defaults-for-user.js');
$modx->regClientStartupScript('/manager/hide-user-fields.js');
}
elseif($my_mode == modSystemEvent::MODE_UPD)
{
$modx->regClientStartupScript('/manager/hide-user-fields.js');
}
}
return;function changeForm()
{
var hide = 'none';
// testing
//var myTest = document.getElementById('modx-user-phone');
//myTest.value = 'NEW User';
// grabs the form, there is only one form to begin with
var myForm = document.forms[0]; // getElementById('ext-gen75'); //ext-gen76
// sets the default values on the form
var mySpecifyPasswordRadio = document.getElementById('modx-user-password-genmethod-s');
mySpecifyPasswordRadio.checked = 'checked';
// shows the password fields
var myPasswordBox = document.getElementById('modx-user-panel-newpassword');
myPasswordBox.style.display = '';
var myCountryField = document.getElementById('modx-user-country');
myCountryField.value = 'United States';
// sets hidden field - THIS IS IMPORTANT!!! - if the field has a hidden field right next to it, then the hidden field needs to be set
var myCountryFieldHidden = myForm.elements['country'];
myCountryFieldHidden.value = 'United States';
var myActiveBox = document.getElementById('modx-user-active');
myActiveBox.checked = true;
// sets hidden field - THIS IS IMPORTANT!!! - if the field has a hidden field right next to it, then the hidden field needs to be set
var myActiveFieldHidden = myForm.elements['active'];
myActiveFieldHidden.value = '1';
// hide all tabs for new users only, except the first and last one (will attempt to set default Access Permissions later)
var myListItems = document.getElementById('modx-user-tabs').getElementsByTagName('li');
for( var x = 1; x < (myListItems.length - 1); x++ )
{
myListItems[x].style.display = hide;
}
// hide fields for new users only
// names of the fields to hide
var names = new Array();
names[0] = "modx-user-passwordnotifymethod-e";
names[1] = "modx-user-password-genmethod-g";
names[2] = "modx-user-active";
names[3] = "modx-user-fs-blocked";
// levels to climb up to hide the entire row that contains the field
var levels = new Array();
levels[0] = 8;
levels[1] = 8;
levels[2] = 3;
levels[3] = 0;
// climbs up to the correct level and hides that row
for( var x = 0; x < names.length; x++ )
{
var tempField = document.getElementById( names[x] );
var i = 0;
while( i < levels[x] )
{
var tempField = tempField.parentNode;
i++;
}
tempField.style.display = hide;
}
}
// delays call so that the form loads
setTimeout("changeForm()", 1500);
function hideFormFields()
{
// hide other fields
var hide = 'none';
// names of the fields to hide
var names = new Array();
names[0] = "modx-user-phone";
names[1] = "modx-user-mobilephone";
names[2] = "modx-user-address";
names[3] = "modx-user-city";
names[4] = "modx-user-fax";
names[5] = "modx-user-state";
names[6] = "modx-user-zip";
names[7] = "modx-user-website";
names[8] = "modx-user-dob";
names[9] = "modx-user-gender";
names[10] = "modx-user-class-key";
names[11] = "modx-user-comment";
// levels to climb up to hide the entire row that contains the field
var levels = new Array();
levels[0] = 2;
levels[1] = 2;
levels[2] = 2;
levels[3] = 2;
levels[4] = 2;
levels[5] = 2;
levels[6] = 2;
levels[7] = 2;
levels[8] = 3;
levels[9] = 3;
levels[10] = 2;
levels[11] = 2;
// climbs up to the correct level and hides that row
for( var x = 0; x < names.length; x++ )
{
var tempField = document.getElementById( names[x] );
var i = 0;
while( i < levels[x] )
{
var tempField = tempField.parentNode;
i++;
}
tempField.style.display = hide;
}
}
// delays call so that the form loads
setTimeout("hideFormFields()",1500);
