Hello, i've create this custom register form
<!-- Row for main content area -->
<div id="content" class="left eight columns" role="main">
<div class="post-box">
<?php get_template_part('/includes/content', 'page'); ?>
<div class="wrapper">
<?php
$err = '';
$success = '';
global $wpdb, $PasswordHash, $current_user, $user_ID;
if(isset($_POST['task']) && $_POST['task'] == 'register' ) {
$pwd1 = $wpdb->escape(trim($_POST['pwd1']));
$pwd2 = $wpdb->escape(trim($_POST['pwd2']));
$first_name = $wpdb->escape(trim($_POST['first_name']));
$last_name = $wpdb->escape(trim($_POST['last_name']));
$email = $wpdb->escape(trim($_POST['email']));
$username = $wpdb->escape(trim($_POST['username']));
if( $email == "" || $pwd1 == "" || $pwd2 == "" || $username == "" || $first_name == "" || $last_name == "") {
$err = 'Devi compilare tutti i campi obbligatori';
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$err = 'Indirizzo email non valido.';
} else if(email_exists($email) ) {
$err = 'Indirizzo email già registrato.';
} else if($pwd1 <> $pwd2 ){
$err = 'Le password non corrispondono.';
} else {
$user_id = wp_insert_user( array ('first_name' => apply_filters('pre_user_first_name', $first_name), 'last_name' => apply_filters('pre_user_last_name', $last_name), 'user_pass' => apply_filters('pre_user_user_pass', $pwd1), 'user_login' => apply_filters('pre_user_user_login', $username), 'user_email' => apply_filters('pre_user_user_email', $email), 'role' => 'subscriber' ) );
if( is_wp_error($user_id) ) {
$err = 'Errore in fase di registrazione';
} else {
do_action('user_register', $user_id);
$success = 'You\'re successfully register';
wp_set_current_user( $user_ID, $current_user );
do_action('set_current_user');
$redirect_to = site_url('www.google.it');
wp_safe_redirect($redirect_to);
}
}
}
?>
<!--display error/success message-->
<div id="message">
<?php
if(! empty($err) ) :
echo '<p class="error">'.$err.'</p>';
endif;
?>
<?php
if(! empty($success) ) :
echo '<p class="error">'.$success.'</p>';
endif;
?>
</div>
<form method="post">
<h3>Registrati al Portale AlpeAdria</h3>
<div class="customregistrazione">
<label class="customregistrazione">Cognome*</label>
<input type="text" value="" name="last_name" id="last_name" style="width: 50%;" />
<label >Nome*</label>
<input type="text" value="" name="first_name" id="first_name" style="width: 50%;" />
<label>Email*</label>
<input type="text" value="" name="email" id="email" style="width: 50%;" />
<label>Username*</label>
<input type="text" value="" name="username" id="username" style="width: 50%;" />
<label>Password*</label>
<input type="password" value="" name="pwd1" id="pwd1" style="width: 50%;" />
<label>Reinserisci Password*</label>
<input type="password" value="" name="pwd2" id="pwd2" style="width: 50%;" />
</div>
<div class="alignleft"><p><?php if($sucess != "") { echo $sucess; } ?> <?php if($err != "") { echo $err; } ?></p></div>
<div>Compilando il seguente form di registrazione il cliente accetta quanto previsto nel disclaimer</div>
<button type="submit" name="btnregister" class="button" >Registrati</button>
<input type="hidden" name="task" value="register" />
</form>
</div>
</div><!-- End Content row -->
<?php get_sidebar( 'right' ); ?>
<?php get_footer();?>
And i want that the user redirect when the registration is ok. Now when visitor make a registration have the succesful message and continue see the form. I like automathic redirect registration to define page http://www.mysite.it/page. Whit my code the form function but not the redirect.
Also i like send an email to subscriber user with details
I try to add this but not function email ($email, "Registrazione OK", "Complimenti registrazione effettuata con successo", "From: email@redacted.com");
Where wrong? How can i resolve?
Thank's