Register

[insert_php]

the_post();
get_header();
[/insert_php]

[insert_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’]));
$plan = $wpdb->escape(trim($_POST[‘plan’]));

if( $email == “” || $pwd1 == “” || $pwd2 == “” || $username == “” || $first_name == “” || $last_name == “” || $plan == “”) {
$err = ‘Please don\’t leave the required fields.’;
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$err = ‘Invalid email address.’;
} else if(email_exists($email) ) {
$err = ‘Email already exist.’;
} else if($pwd1 <> $pwd2 ){
$err = ‘Password do not match.’;
} 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), ‘user_url’ => apply_filters(‘pre_user_user_login’, $plan), ‘role’ => ‘subscriber’ ) );
if( is_wp_error($user_id) ) {
$err = ‘Error on user creation.’;
} else {
do_action(‘user_register’, $user_id);

$success = ‘New Subscriber successfully registered’;
}

}

}
[/insert_php]

ADD A SUBSCRIBER

[insert_php] if(! empty($err) ) : echo ‘

‘.$err.”; endif; [/insert_php]
[insert_php] if(! empty($success) ) : echo ‘

‘.$success.”; return home_url(‘/subscribers-3’); endif; get_header();
[/insert_php]

[insert_php] if($sucess != “”) { echo $sucess; } [/insert_php] [insert_php] if($err != “”) { echo $err; } [/insert_php]