# HG changeset patch # User Kim Alvefur # Date 1385848767 -3600 # Node ID 9277e0a3922fbf373d212e6ea6e0dd20ea19688f # Parent da39ba4047a7ca541089526bd4e4d4b08fa45da6 mod_register_web: Support additional registration fields diff -r da39ba4047a7 -r 9277e0a3922f mod_register_web/mod_register_web.lua --- a/mod_register_web/mod_register_web.lua Sat Nov 30 22:10:41 2013 +0100 +++ b/mod_register_web/mod_register_web.lua Sat Nov 30 22:59:27 2013 +0100 @@ -3,6 +3,12 @@ local usermanager = require "core.usermanager"; local http = require "util.http"; +local extra_fields = { + nick = true; name = true; first = true; last = true; email = true; + address = true; city = true; state = true; zip = true; + phone = true; url = true; date = true; +} + function template(data) -- Like util.template, but deals with plain text return { apply = function(values) return (data:gsub("{([^}]+)}", values)); end } @@ -110,6 +116,16 @@ end local ok, err = usermanager.create_user(prepped_username, form.password, module.host); if ok then + local extra_data = {}; + for field in pairs(extra_fields) do + local field_value = form[field]; + if field_value and #field_value > 0 then + extra_data[field] = field_value; + end + end + if next(first) ~= nil then + datamanager.store(prepped_username, module.host, "account_details", extra_data); + end module:fire_event("user-registered", { username = prepped_username, host = module.host,