What I need to do is send a custom form in the same time that the user subscribes to my Wordpress site. I'm using the hook add_action "user_register", this is my code:
<?php
add_action('user_register', 'my_function');
function my_function($user_id) {
$user_info = get_userdata($user_id);
$username = $user_info->user_login;
$mail = $user_info->user_email;
?>
<form id="my-form" action="http://....." method="get">
<input type="hidden" name="list" value="9">
<input type="email" name="email" value="<?php echo $mail; ?>">
<input type="hidden" name="campo1" value="campo1">
<input type="hidden" name="username" value="<?php echo $username; ?>">
<input type="submit" />
</form>
<script type="text/javascript">
document.getElementById('my-form').submit();
</script>
<?php } ?>
What am I doing wrong? The function is working, the hook too with a different function. For example I tryed something like that:
<?php
add_action('user_register', 'my_function');
function my_function($user_id) {
$user_info = get_userdata($user_id);
$username = $user_info->user_login;
$mail = $user_info->user_email;
update_option('mail_test', $mail);
} ?>
Any ideas? Thanks in advance for your help.