I was able to cobble together code that does what I need. Hope this will help someone else. It’s brute force, but it works. Perhaps Jason will want to smooth out the loose ends?
I am concatenating 2 checkbox values and 3 text box values to create the userid I want. Then I am using the Email Login plugin by Beau Lebens to allow the user to login with their email address, so they don’t have to remember this long userid. The userids are ugly but quite useful to my client.
<?php
add_action ("login_head", "s2_customize_login", 1000);
function s2_customize_login ()
{
/* 12/18/12 - DFG Strip all blanks out of first and last name. Concatenate
N/S + unitnum + first + last + Status. */
?>
<script type = "text/javascript">
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
(function ($) /* Wraps this `$ = jQuery` routine. */
{
$.fn.swapWith = function (to) /* Utility extension for jQuery. */
{
return this.each (function ()
{
var $to = $ (to).clone (true), $from = $ (this).clone (true);
$(to).replaceWith ($from), $ (this).replaceWith ($to);
});
};
/**/
$(document).ready (function () /* Handles email-to-username on keyup. */
{
/* If this is the register page, customize it */
if(getParameterByName('action') == 'register')
{
var login = 'input#user_login';
var firstname = 'input#ws-plugin--s2member-custom-reg-field-first-name';
var lastname = 'input#ws-plugin--s2member-custom-reg-field-last-name';
var unitnumber = 'input#ws-plugin--s2member-custom-reg-field-unit-number';
var valNS ;
var valRES ;
var newfirst ;
var newlast ;
var newunit ;
$(login).closest ('p').hide(); // This hides the closest P above the login field,
// which is the p containing the login field.
$('input:radio[name=ws_plugin__s2member_custom_reg_field_north_south]').click(function() {
valNS = $('input:radio[name=ws_plugin__s2member_custom_reg_field_north_south]:checked').val();
$(login).val( valNS + newunit + "_" + newfirst + "_" + newlast + "_" + valRES );
});
$('input:radio[name=ws_plugin__s2member_custom_reg_field_resident_status]').click(function() {
valRES = $('input:radio[name=ws_plugin__s2member_custom_reg_field_resident_status]:checked').val();
$(login).val( valNS + newunit + "_" + newfirst + "_" + newlast + "_" + valRES );
});
$ (firstname).blur (function ()
{
newfirst = $.trim( $(firstname).val() );
newfirst = newfirst.split(' ').join('');
$(login).val( valNS + newunit + "_" + newfirst + "_" + newlast + "_" + valRES );
});
$ (lastname).blur (function ()
{
newlast = $.trim( $(lastname).val() );
newlast = newlast.split(' ').join('');
$(login).val( valNS + newunit + "_" + newfirst + "_" + newlast + "_" + valRES );
});
$ (unitnumber).blur (function ()
{
newunit = $.trim( $(unitnumber).val() );
$(login).val( valNS + newunit + "_" + newfirst + "_" + newlast + "_" + valRES );
});
}
});
}) (jQuery);
</script>
<?php
}
?>
Thanks again to Jason and Raam for the code model.