Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Appcelerator Register with custom fields
var sex = (male == 1) ? 'male' : 'female';
var data = {
email: email.value,
first_name: global.user_names[0],
last_name: global.user_names[1],
password: password.value,
password_confirmation: password.value,
custom_fields: '{ "dob": "'+ dob.value +'", "sex": "'+ sex +'" }' // REMOVE THIS LINE IT ALL WORKS... HAVE HAD MULTIPLE PEDRMEATATIONS, SO THIS WAY MAY NOT BE THE ONLY CAUSE OF THIS NOT WORKING, JUST THE LAST ONE I TRIED.
};
sdk.sendRequest('users/create.json', 'POST', data, false, callback);
function callback(data) {
if(data) {
if(data.meta) {
var meta = data.meta;
if(meta.status == 'ok' && meta.code == 200 && meta.method_name == 'createUser') {
var message = '';
var user = data.response.users[0];
Ti.API.info("User id is => " + user.id);
var cred = [user.id, email.value];
Ti.App.Properties.setString('credentials', cred);
keychain.setPasswordForService(password.value, 'Heritage', email.value);
Ti.App.fireEvent('accountLoggedIn');
} else{
alert(meta.status +' ' + meta.code)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.