function email_needed() { global $f; $f = new xsValidateForm(); $f->setRule('xs_email', 'Email Id', 'trim|required|valid_email|callback[fnValidateEmail]'); if ($f->validate()) { // sign up and create acc print_r( $_SESSION ); $data = ['user_login' => $_SESSION['src'] . '_' . $_SESSION['id'], 'user_email' => $_POST['xs_email'], 'first_name' => $_SESSION['fname'], 'last_name' => $_SESSION['lname'], 'user_pass' => substr(wp_hash(time() . rand(0, 100000)), 0, 8), 'role' => $_SESSION['role']]; $user = wp_insert_user($data); if ($user > 0) { if (xsUTL::log_user($user)) { $this->okMsg = "Registration Successful.Please wait..."; $this->redirect = SURL . '/my-account/'; } } xsUTL::addError('Sign Up failed'); } else { $this->error = $f->returnErrors(); } }
function _init() { session_start(); include_once 'classes/xsUTL.php'; require_once "Hybrid/Auth.php"; // if (isset($_GET['_login'])) { switch ($_GET['_login']) { case 'tw': $src = 'Twitter'; break; case 'fb': $src = 'Facebook'; break; case 'gp': $src = "Google"; break; } } $config = dirname(__FILE__) . '/config.php'; try { $hybridauth = new Hybrid_Auth($config); $social_login = $hybridauth->authenticate($src); $user_profile = $social_login->getUserProfile(); $id = $user_profile->identifier; $name = $user_profile->displayName; $fname = $user_profile->firstName; $lname = $user_profile->lastName; $email = $user_profile->email; //creates the user if (!is_email($email)) { $_SESSION['role'] = $_SESSION['xs_user_type']; $_SESSION['src'] = $_GET['hauth.done']; $_SESSION['fname'] = $fname; $_SESSION['lname'] = $lname; $_SESSION['id'] = $id; // redirect to enter email wp_redirect(SURL . '/email-needed/'); die; } if (email_exists($email)) { //logs user $user = get_user_by('email', $email); $logged_in = xsUTL::log_user($user->ID); if ($logged_in) { wp_redirect(SURL . '/my-account/'); } die('Error'); } $_role = $_SESSION['xs_user_type']; $data = ['user_login' => $src . '_' . $id, 'user_email' => $email, 'first_name' => $fname, 'last_name' => $lname, 'user_pass' => substr(wp_hash(time() . rand(0, 100000)), 0, 8), 'role' => $_role]; $user = wp_insert_user($data); if ($user > 0) { if (xsUTL::log_user($user)) { wp_redirect(SURL . '/my-account/'); } die('Error'); } xsUTL::addError('Sign Up failed'); } catch (Exception $e) { } // Form Processsor if ($_POST['_act'] && !is_admin()) { $_form_processor = new xsFormProcess(); die; } }