function wpestate_ajax_register_form_booking()
 {
     check_ajax_referer('register_ajax_nonce', 'security-register');
     $user_email = trim($_POST['user_email_register']);
     $user_name = trim($_POST['user_login_register']);
     $group = trim($_POST['group_register']);
     if (preg_match("/^[0-9A-Za-z_]+\$/", $user_name) == 0) {
         print esc_html__('Invalid username( *do not use special characters or spaces ) ', 'wpestate');
         die;
     }
     //  print '$user_email '.$user_email.' $user_name '.$user_name.' $group'.$group;
     if ($user_email == '' || $user_name == '') {
         print esc_html__('Username and/or Email field is empty!', 'wpestate');
         exit;
     }
     if (filter_var($user_email, FILTER_VALIDATE_EMAIL) === false) {
         print esc_html__('The email doesn\'t look right !', 'wpestate');
         exit;
     }
     $domain = substr(strrchr($user_email, "@"), 1);
     if (!checkdnsrr($domain)) {
         print esc_html__('The email\'s domain doesn\'t look right.', 'wpestate');
         exit;
     }
     $user_id = username_exists($user_name);
     if ($user_id) {
         print esc_html__('Username already exists.  Please choose a new one.', 'wpestate');
         exit;
     }
     if (!$user_id && email_exists($user_email) == false) {
         $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
         $user_id = wp_create_user($user_name, $random_password, $user_email);
         if (is_wp_error($user_id)) {
             print_r($user_id);
         } else {
             print esc_html__('An email with the generated password was sent!', 'wpestate');
             wpestate_update_profile_booking($user_id, $group);
             wpestate_wp_new_user_notification($user_id, $random_password);
             if ('renter' == $group) {
                 wpestate_register_as_user($user_name, $user_id);
             }
         }
     } else {
         print esc_html__('Email already exists.  Please choose a new one.', 'wpestate');
     }
     die;
 }
Пример #2
0
 function wpestate_ajax_register_form()
 {
     if (!check_ajax_referer('register_ajax_nonce', 'security-register', true) == 1) {
         check_ajax_referer('register_ajax_nonce', 'security-register-mobile');
     }
     $allowed_html = array();
     $user_email = trim(wp_kses($_POST['user_email_register'], $allowed_html));
     $user_name = trim(wp_kses($_POST['user_login_register'], $allowed_html));
     if (preg_match("/^[0-9A-Za-z_]+\$/", $user_name) == 0) {
         echo json_encode(array('register' => false, 'message' => esc_html__('Invalid username (do not use special characters or spaces)!', 'wpestate')));
         die;
     }
     if ($user_email == '' || $user_name == '') {
         echo json_encode(array('register' => false, 'message' => esc_html__('Username and/or Email field is empty!', 'wpestate')));
         exit;
     }
     if (filter_var($user_email, FILTER_VALIDATE_EMAIL) === false) {
         echo json_encode(array('register' => false, 'message' => esc_html__('The email doesn\'t look right!', 'wpestate')));
         exit;
     }
     $domain = substr(strrchr($user_email, "@"), 1);
     if (!checkdnsrr($domain)) {
         echo json_encode(array('register' => false, 'message' => esc_html__('The email\'s domain doesn\'t look right!', 'wpestate')));
         exit;
     }
     $user_id = username_exists($user_name);
     if ($user_id) {
         echo json_encode(array('register' => false, 'message' => esc_html__('Username already exists.  Please choose a new one.!', 'wpestate')));
         exit;
     }
     if (!$user_id and email_exists($user_email) == false) {
         $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
         $user_id = wp_create_user($user_name, $random_password, $user_email);
         if (is_wp_error($user_id)) {
             print_r($user_id);
         } else {
             echo json_encode(array('register' => true, 'message' => esc_html__('An email with the generated password was sent', 'wpestate')));
             wpestate_update_profile($user_id);
             wpestate_wp_new_user_notification($user_id, $random_password);
             wpestate_register_as_user($user_name, $user_id);
         }
     } else {
         echo json_encode(array('register' => false, 'message' => esc_html__('Email already exists.  Please choose a new one!', 'wpestate')));
     }
     die;
 }
Пример #3
0
 function wpestate_ajax_register_form()
 {
     if (!check_ajax_referer('register_ajax_nonce', 'security-register', true) == 1) {
         check_ajax_referer('register_ajax_nonce', 'security-register-mobile');
     }
     $allowed_html = array();
     $user_email = trim(wp_kses($_POST['user_email_register'], $allowed_html));
     $user_name = trim(wp_kses($_POST['user_login_register'], $allowed_html));
     $user_password = trim(wp_kses($_POST['user_password_register'], $allowed_html));
     if (preg_match("/^[0-9A-Za-z_]+\$/", $user_name) == 0) {
         echo json_encode(array('register' => false, 'message' => esc_html__('Invalid username (do not use special characters or spaces)!', 'wpestate')));
         die;
     }
     if ($user_email == '' || $user_name == '') {
         echo json_encode(array('register' => false, 'message' => esc_html__('Username and/or Email field is empty!', 'wpestate')));
         exit;
     }
     if (filter_var($user_email, FILTER_VALIDATE_EMAIL) === false) {
         echo json_encode(array('register' => false, 'message' => esc_html__('The email doesn\'t look right!', 'wpestate')));
         exit;
     }
     $domain = substr(strrchr($user_email, "@"), 1);
     if (!checkdnsrr($domain)) {
         echo json_encode(array('register' => false, 'message' => esc_html__('The email\'s domain doesn\'t look right!', 'wpestate')));
         exit;
     }
     $user_id = username_exists($user_name);
     if ($user_id) {
         echo json_encode(array('register' => false, 'message' => esc_html__('Username already exists.  Please choose a new one.!', 'wpestate')));
         exit;
     }
     if (!$user_id and email_exists($user_email) == false) {
         $user_id = wp_create_user($user_name, $user_password, $user_email);
         if (is_wp_error($user_id)) {
             print_r($user_id);
         } else {
             echo json_encode(array('register' => true, 'message' => esc_html__('A new account has been created successfully.', 'wpestate')));
             wpestate_update_profile($user_id);
             wpestate_wp_new_user_notification($user_id, $user_password);
             wpestate_register_as_user($user_name, $user_id);
             $vsessionid = session_id();
             session_start();
             if (empty($vsessionid)) {
                 session_name('PHPSESSID');
             }
             wp_clear_auth_cookie();
             $info = array();
             $info['user_login'] = $user_name;
             $info['user_password'] = $user_password;
             $info['remember'] = true;
             $user_signon = wp_signon($info, true);
             if (is_wp_error($user_signon)) {
                 echo json_encode(array('register' => false, 'message' => esc_html__('Wrong username or password!', 'wpestate')));
             } else {
                 wp_set_current_user($user_signon->ID);
                 do_action('set_current_user');
                 global $current_user;
                 $current_user = wp_get_current_user();
                 wpestate_update_old_users($user_signon->ID);
             }
         }
     } else {
         echo json_encode(array('register' => false, 'message' => esc_html__('Email already exists.  Please choose a new one!', 'wpestate')));
     }
     die;
 }