I need to create a action/hook to get a a form element value when a user submit the user registration form.
My registration form has the elements:
- user
- password
- nif
I need to creat an action to get the value of 'nif'. I found this which should be my starting point, but I don't know how to retrieve the value of 'nif'.
add_action( 'user_register', 'registration_get_nif', 10, 1 );
function registration_get_nif( $user_id ) {
// HERE. GET VALUE OF 'nif'....
}
Presuming your form has an input with the name
nif
you can use PHP's $_POST variable.You'll want to heavily sanitise that variable, as it can be manipulated by the browser.