Perform a function when a user clicks register button

You can hook your function with user_register. It will fire immediately after an user registration is done. And user id is passed to hook as an argument.

add_action( 'user_register', 'my_custom_function' );
function my_custom_function ( $user_id  ) {
    //here goes your code
}