PerBonomi
10 years agoBoss
Increase completed registrations?
Hi there. I was thinking this morning, that maybe we could help new users complete their registration if we suggest a username for them, and I couldn't figure out the XML Text generator for sso users.
Hence this basic code. Anyone want to pick it apart?
Basically, on the page where you've already logged in through sso, but haven't picked a username yet I check if a user with your sso already exists and either suggest your sso as username, or loop through variations(sso_1,sso_2,etc.) to find an available name.
<#if !user.anonymous> <#attempt> <#assign usersso = restadmin("/users/id/${user.id}/sso_id").value /> <#recover> <#assign usersso = "" /> </#attempt> </#if> <#if usersso?? && usersso != ""> <#attempt> <#assign userNameExists = restadmin("/users/login/${usersso}/login").value/> <#recover> <#assign userNameExists = "N"/> <#assign userName = usersso/> </#attempt> </#if> <#if userNameExists??> <#if userNameExists != "N"> <#list 1..50 as u> <#attempt> <#assign userNameExists = restadmin("/users/login/${usersso}_${u}/login").value/> <#recover> <#assign userNameExists = "N"/> <#assign userName = "${usersso}_${u}"/> </#attempt> <#if userNameExists == "N"> <#break> </#if> </#list> </#if> <#if userName??> <script> $(window).load( function() { $("#lia-login").val('${userName}'); }); </script> </#if> </#if>