I was wrong with the code above.
It's because you try to get a handle on the person document even though the forum config says NO to registration (and thus have not supplied any names.nsf details). So I changed this:
'Check if registration is allowed
If ctx.IsNewNote And profile.GetItemValue("AllowRegistration")(0) <> "YES" Then<br/>
ErrorCode="1"<br/>
Goto ErrorHandler<br/>
End If <br/>
<br/>
Set dbreg = s.GetDatabase("",profile.GetItemValue("NABFile")(0))<br/>
Set dbreggroup = s.GetDatabase("",profile.GetItemValue("NABGroupFile")(0))<br/>
<br/>
Set viewreg=dbreg.GetView("($Users)")<br/>
<br/>
username = ctx.GetItemValue("Username")(0)<br/>
Set docpeople = viewreg.GetDocumentByKey(username,True)<br/>
<br/>
If ctx.IsNewNote And Not (docpeople Is Nothing) Then <br/>
ErrorCode="2"<br/>
Goto ErrorHandler<br/>
End If<br/>
to this:
'Check if registration is allowed
If ctx.IsNewNote And profile.GetItemValue("AllowRegistration")(0) <> "YES" Then<br/>
ErrorCode="1"<br/>
Goto ErrorHandler<br/>
End If <br/>
<br/>
If profile.GetItemValue("AllowRegistration")(0) = "YES" Then<br/>
Set dbreg = s.GetDatabase("",profile.GetItemValue("NABFile")(0))<br/>
Set dbreggroup = s.GetDatabase("",profile.GetItemValue("NABGroupFile")(0))<br/>
<br/>
Set viewreg=dbreg.GetView("($Users)")<br/>
<br/>
username = ctx.GetItemValue("Username")(0)<br/>
Set docpeople = viewreg.GetDocumentByKey(username,True)<br/>
<br/>
If ctx.IsNewNote And Not (docpeople Is Nothing) Then <br/>
ErrorCode="2"<br/>
Goto ErrorHandler<br/>
End If<br/>
<br/>
End If