function uultra_handle_errors() { global $xoouserultra; //require_once(ABSPATH . 'wp-includes/pluggable.php'); if (get_option('users_can_register') == '1') { foreach ($this->usermeta as $key => $value) { /* Validate username */ if ($key == 'user_login') { if (esc_attr($value) == '') { $this->errors[] = __('<strong>ERROR:</strong> Please enter a username.', 'xoousers'); } elseif (username_exists($value)) { $this->errors[] = __('<strong>ERROR:</strong> This username is already registered. Please choose another one.', 'xoousers'); } } /* Validate email */ if ($key == 'user_email') { if (esc_attr($value) == '') { $this->errors[] = __('<strong>ERROR:</strong> Please type your e-mail address.', 'xoousers'); } elseif (!is_email($value)) { $this->errors[] = __('<strong>ERROR:</strong> The email address isn\'t correct.', 'xoousers'); } elseif ($value != $_POST['user_email_2']) { $this->errors[] = __('<strong>ERROR:</strong> The emails are different.', 'xoousers'); } elseif (email_exists($value)) { $this->errors[] = __('<strong>ERROR:</strong> This email is already registered, please choose another one.', 'xoousers'); } } } //check if auto-password $auto_password = $xoouserultra->get_option("set_password"); if ($auto_password == '' || $auto_password == 1) { /* Validate passowrd */ if ($_POST["user_pass"] == "") { $this->errors[] = __('<strong>ERROR:</strong> Please type your password.', 'xoousers'); } if ($_POST["user_pass"] != $_POST["user_pass_confirm"]) { $this->errors[] = __('<strong>ERROR:</strong> The passwords must be identical', 'xoousers'); } //password strenght $this->uultra_check_pass_strenght($_POST["user_pass"]); } if (!is_in_post('no_captcha', 'yes')) { if (!$xoouserultra->captchamodule->validate_captcha(post_value('captcha_plugin'))) { $this->errors[] = __('<strong>ERROR:</strong> Please complete Captcha Test first.', 'xoousers'); } } } else { $this->errors[] = __('<strong>ERROR:</strong> Registration is disabled for this site.', 'xoousers'); } }
public function upme_reset_module_settings() { global $upme_admin; if (is_post() && is_in_post('current_tab')) { if (isset($upme_admin->default_module_settings[post_value('current_tab')])) { $current_options = get_option('upme_options'); foreach ($upme_admin->default_module_settings[post_value('current_tab')] as $key => $value) { $current_options[$key] = $value; } update_option('upme_options', $current_options); echo json_encode(array('status' => 'success')); exit; } } }
function handle() { global $upme_captcha_loader; require_once ABSPATH . 'wp-includes/pluggable.php'; if (get_option('users_can_register') == '1') { foreach ($this->usermeta as $key => $value) { /* Validate username */ if ($key == 'user_login') { /* UPME Action for validating username before creating new user */ do_action('upme_validate_username', $value); // End Action if (esc_attr($value) == '') { $this->errors[] = __('Please enter a username.', 'upme'); } elseif (username_exists($value)) { $this->errors[] = __('This username is already registered. Please choose another one.', 'upme'); } } /* Validate email */ if ($key == 'user_email') { if (esc_attr($value) == '') { $this->errors[] = __('Please type your e-mail address.', 'upme'); } elseif (!is_email($value)) { $this->errors[] = __('The email address isn\'t correct.', 'upme'); } elseif (email_exists($value)) { $this->errors[] = __('This email is already registered, please choose another one.', 'upme'); } } /* UPME filter for adding restrictions before custom field type saving */ $registration_custom_field_type_restrictions_params = array('meta' => $key, 'value' => $value); $this->errors = apply_filters('upme_registration_custom_field_type_restrictions', $this->errors, $registration_custom_field_type_restrictions_params); /* END filter */ } if (!is_in_post('no_captcha', 'yes')) { if (!$upme_captcha_loader->validate_captcha(post_value('captcha_plugin'))) { $this->errors[] = __('Please complete Captcha Test first.', 'upme'); } } } else { $this->errors[] = __('Registration is disabled for this site.', 'upme'); } }
function handle() { global $xoousersultra_captcha_loader, $xoouserultra, $blog_id; require_once ABSPATH . 'wp-includes/user.php'; if (empty($GLOBALS['wp_rewrite'])) { $GLOBALS['wp_rewrite'] = new WP_Rewrite(); } $noactive = false; foreach ($this->usermeta as $key => $value) { if ($key == 'user_login') { if (sanitize_user($value) == '') { $this->errors[] = __('<strong>ERROR:</strong> The username field is empty.', 'xoousers'); } } if ($key == 'user_pass') { if (esc_attr($value) == '') { $this->errors[] = __('<strong>ERROR:</strong> The password field is empty.', 'xoousers'); } } } // Check captcha first if (!is_in_post('no_captcha', 'yes')) { } /* attempt to signon */ if (!is_array($this->errors)) { $creds = array(); // Adding support for login by email if (is_email($_POST['user_login'])) { $user = get_user_by('email', $_POST['user_login']); if (isset($user->data->user_login)) { $creds['user_login'] = $user->data->user_login; } else { $creds['user_login'] = ''; } // check if active $user_id = $user->ID; if (!$this->is_active($user_id)) { $noactive = true; } } else { // User is trying to login using username $user = get_user_by('login', $_POST['user_login']); // check if active and it's not an admin if (isset($user)) { $user_id = $user->ID; } else { $user_id = ""; } if (!$this->is_active($user_id) && !is_super_admin($user_id)) { $noactive = true; } $creds['user_login'] = sanitize_user($_POST['user_login']); } $creds['user_password'] = $_POST['login_user_pass']; $creds['remember'] = $_POST['rememberme']; if (!$noactive) { //echo "step e"; $user = wp_signon($creds, false); do_action('wp_login', $user->user_login, $user); if (is_wp_error($user)) { //echo "TTEES here" ; if ($user->get_error_code() == 'invalid_username') { $this->errors[] = __('<strong>ERROR:</strong> Invalid Username was entered.', 'xoousers'); } if ($user->get_error_code() == 'incorrect_password') { $this->errors[] = __('<strong>ERROR:</strong> Incorrect password was entered.', 'xoousers'); } if ($user->get_error_code() == 'empty_password') { $this->errors[] = __('<strong>ERROR:</strong> Please provide Password.', 'xoousers'); } } else { wp_set_auth_cookie($user->ID); wp_set_current_user($user->ID); do_action('wp_login', $user->user_login); $this->login_registration_afterlogin(); } } else { //not active $this->errors[] = __('<strong>ERROR:</strong> Your account is not active.', 'xoousers'); } } }
function handle() { global $upme_captcha_loader; // Verify whether login form name is modified if (isset($_POST['upme-hidden-login-form-name'])) { $upme_secret_key = get_option('upme_secret_key'); $login_form_name = $_POST['upme-hidden-login-form-name']; $login_form_name_hash = $_POST['upme-hidden-login-form-name-hash']; if ($login_form_name_hash != hash('sha256', $login_form_name . $upme_secret_key)) { // Invailid form name was defined by manually editing $this->errors[] = __('Invalid login form.', 'upme'); return; } $this->login_form_name = $login_form_name; } require_once ABSPATH . 'wp-includes/pluggable.php'; foreach ($this->usermeta as $key => $value) { if ($key == 'user_login') { if (sanitize_user($value) == '') { $this->errors[] = __('The username field is empty.', 'upme'); } } if ($key == 'user_pass') { if (esc_attr($value) == '') { $this->errors[] = __('The password field is empty.', 'upme'); } } } /* UPME action for adding restrictions before login */ $before_login_validation_params = array(); do_action('upme_before_login_restrictions', $this->usermeta, $before_login_validation_params); /* END action */ // Check approval status and activation status before login if (isset($_POST['user_login']) && '' != $_POST['user_login']) { // Check whether email or username is used for login $user_email_check = email_exists($_POST['user_login']); if ($user_email_check) { $user_data = new stdClass(); $user_data->ID = $user_email_check; } else { $user_data = get_user_by('login', $_POST['user_login']); if (!$user_data) { $user_data = new stdClass(); $user_data->ID = ''; } } if ('INACTIVE' == get_user_meta($user_data->ID, 'upme_approval_status', true)) { $this->errors[] = $this->upme_settings['html_profile_approval_pending_msg']; } else { if ('INACTIVE' == get_user_meta($user_data->ID, 'upme_activation_status', true)) { $this->errors[] = __('Please confirm your email to activate your account.', 'upme'); } } } // Check captcha first if (!is_in_post('no_captcha', 'yes')) { if (!$upme_captcha_loader->validate_captcha(post_value('captcha_plugin'))) { $this->errors[] = __('Please complete Captcha Test first.', 'upme'); } } /* attempt to signon */ if (!is_array($this->errors)) { $creds = array(); // Adding support for login by email if (is_email($_POST['user_login'])) { $user = get_user_by('email', $_POST['user_login']); if ($user) { if (isset($user->data->user_login)) { $creds['user_login'] = $user->data->user_login; } else { $creds['user_login'] = ''; } } else { $creds['user_login'] = sanitize_user($_POST['user_login'], TRUE); } } else { $creds['user_login'] = sanitize_user($_POST['user_login'], TRUE); } $creds['user_password'] = $_POST['login_user_pass']; $creds['remember'] = $_POST['rememberme']; $secure_cookie = false; if (is_ssl()) { $secure_cookie = true; } /* UPME Action validating before login */ do_action('upme_validate_login', $creds); // End Action if (!$this->errors) { $user = wp_signon($creds, $secure_cookie); if (is_wp_error($user)) { if ($user->get_error_code() == 'invalid_username') { $this->errors[] = __('Invalid Username or Email', 'upme'); } if ($user->get_error_code() == 'incorrect_password') { $this->errors[] = __('Incorrect Username or Password', 'upme'); } if ($user->get_error_code() == 'empty_password') { $this->errors[] = __('Please enter a password.', 'upme'); } /* UPME action for adding actions after unsuccessfull login */ $login_failed_params = array(); do_action('upme_login_failed', $this->usermeta, $user, $login_failed_params); /* END action */ } else { do_action('wp_login'); /* UPME action for adding actions after successfull login */ $login_sucess_params = array(); do_action('upme_login_sucess', $this->usermeta, $user, $login_sucess_params); /* END action */ } } } }
private function validate_recaptcha() { global $upme; $this->load_recaptcha_class(); // Getting the Private Key to validate reCaptcha $private_key = ''; $private_key = $upme->get_option('recaptcha_private_key'); if ($private_key != '') { if (is_in_post('recaptcha_response_field')) { $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], post_value("recaptcha_challenge_field"), post_value("recaptcha_response_field")); // Captcha is Valid if ($resp->is_valid) { return true; } else { return false; } } else { return true; } } else { // Private key is not set in admin return true; } }
function upme_reset_settings() { if (is_post() && is_in_post('current_tab')) { if (isset($this->default_settings[post_value('current_tab')])) { $current_options = get_option('upme_options'); foreach ($this->default_settings[post_value('current_tab')] as $key => $value) { $current_options[$key] = $value; } update_option('upme_options', $current_options); echo "success"; die; } } }
function check_search_input() { if (is_post()) { if (is_in_post('upme_combined_search') && post_value('upme_combined_search') != '') { return true; } if (is_in_post('upme_search')) { foreach ($_POST['upme_search'] as $key => $value) { if (is_array($value) && count($value) > 0) { return true; } else { if ($value != '' && $value != '0') { return true; } } } } } return false; }