Upon registration using Solspace User, I would like to force the submitted username to be equal to first_name|last_name, similar to how the Screen Name is created. Is this possible?
2 Answers
Unfortunately this isn't possible. I recommend submitting this as a Feature Request under the specific add-on category. It'll also give other users the option to vote up the feature request, and help us prioritize features to add in upcoming versions of this add-on. http://support.solspace.com/support/discussions
I do this with a bit of javascript.
<script>
$().ready(function() {
$("#username").focus(function() {
var firstname = $("#first_name").val();
var lastname = $("#last_name").val();
var letter = firstname.charAt(0).toLowerCase();
var lname = lastname.toLowerCase().replace(/\s/g, "");
if(letter && lastname && !this.value) {
this.value = letter + lname;
}
});
</script>
-
Could you expand this answer to include back-end validation? This method allows any user with a developer console to override this method. Commented Sep 29, 2015 at 19:31