Wordpress: action/hook to get a form element value on user registration form?

540 Views Asked by At

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'....

}
1

There are 1 best solutions below

2
On

Presuming your form has an input with the name nif you can use PHP's $_POST variable.

$nif = $_POST['nif'];

You'll want to heavily sanitise that variable, as it can be manipulated by the browser.