Closed stsier closed 6 years ago
Not an issue but a way to register new user with a lang code:
jDrupal.userRegister = function(name, pass, mail, lang) { return new Promise(function(resolve, reject) { var req = new XMLHttpRequest(); req.dg = { service: 'user', resource: 'register' }; req.open('POST', jDrupal.restPath() + 'user/register?_format=json'); req.setRequestHeader('Content-type', 'application/json');
var connected = function() { jDrupal.connect().then(resolve); }; req.onload = function() { if (req.status == 200) { var invoke = jDrupal.moduleInvokeAll('rest_post_process', req); if (!invoke) { connected(); } else { invoke.then(connected); } } else { reject(req); } }; req.onerror = function() { reject(Error("Network Error")); }; req.send(JSON.stringify({ name: {value : name}, pass: {value: pass}, mail: {value: mail}, preferred_langcode:{value:lang} }));
}); };
where lang is 'en', 'fr', 'es' etc
otherwise user is registered with the site's default language even from a non-default language interface
@stsier Thank you for sharing!
Not an issue but a way to register new user with a lang code:
jDrupal.userRegister = function(name, pass, mail, lang) { return new Promise(function(resolve, reject) { var req = new XMLHttpRequest(); req.dg = { service: 'user', resource: 'register' }; req.open('POST', jDrupal.restPath() + 'user/register?_format=json'); req.setRequestHeader('Content-type', 'application/json');
}); };
where lang is 'en', 'fr', 'es' etc
otherwise user is registered with the site's default language even from a non-default language interface