Hook/lock custom parameter

I’m passing a custom parameter to the lock with no issues:
webAuth.authorise({ foo: ‘bar’ });
I’d like to be able to access this parameter in the pre-registration hook, but can’t figure out if there is a way to do this.

Pre-registration Hooks only run during sign up events; the webAuth.authorize() method is a login method, rather than a sign up method. You can pass a custom parameter during the signup as follows:

webAuth.signup({ 
	connection: 'Username-Password-Authentication', 
	email: $('.signup-email').val(), 
	password: $('.signup-password').val(),
	user_metadata: {
		foo: 'bar'
	}
}, function (err) { 
	if (err) return alert('Something went wrong: ' + err.message); 
	    return alert('success signup without login!') 
}); 

You can then access the user.user_metadata.foo property in the pre-registration hook.

Thanks for the response. webAuth.Authorize({ foo: ‘bar’ }) is the way we sign users up. We are using the hosted login page and the lock there is configured to allow signups. I can access “foo” in the lock using config.extraParams with no issues. The question is how do we pass “foo” from the lock on the hosted login page to the pre-reg hook? The scenario here is a trusted client, so there are no issues with the users potentially being able to change “foo”.

For the time being, I’m using a hacky work around, which is to create a pre-filled custom field on the sign-up using additionalSignUpFields which I then hide using CSS.