function rcl_confirm_user_registration()
{
    global $wpdb, $rcl_options;
    $reglogin = $_GET['rglogin'];
    $regpass = $_GET['rgpass'];
    $regcode = md5($reglogin);
    if ($regcode == $_GET['rgcode']) {
        if ($user = get_user_by('login', $reglogin)) {
            wp_update_user(array('ID' => $user->ID, 'role' => get_option('default_role')));
            $time_action = current_time('mysql');
            $action = $wpdb->get_var($wpdb->prepare("SELECT time_action FROM " . RCL_PREF . "user_action WHERE user = '******'", $user->ID));
            if (!$action) {
                $wpdb->insert(RCL_PREF . 'user_action', array('user' => $user->ID, 'time_action' => $time_action));
            }
            $creds = array();
            $creds['user_login'] = $reglogin;
            $creds['user_password'] = $regpass;
            $creds['remember'] = true;
            $sign = wp_signon($creds, false);
            if (!is_wp_error($sign)) {
                rcl_update_timeaction_user();
                do_action('rcl_confirm_registration', $user->ID);
                wp_redirect(rcl_get_authorize_url($user->ID));
                exit;
            }
        }
    }
    if ($rcl_options['login_form_recall'] == 2) {
        wp_safe_redirect('wp-login.php?checkemail=confirm');
    } else {
        wp_redirect(get_bloginfo('wpurl') . '?action-rcl=login&error=confirm');
    }
    exit;
}
function rcl_get_login_user()
{
    global $wp_errors;
    $pass = sanitize_text_field($_POST['user_pass']);
    $login = sanitize_user($_POST['user_login']);
    $member = isset($_POST['rememberme']) ? intval($_POST['rememberme']) : 0;
    $url = esc_url($_POST['redirect_to']);
    $wp_errors = new WP_Error();
    if (!$pass || !$login) {
        $wp_errors->add('rcl_login_empty', __('Fill in the required fields!', 'wp-recall'));
        return $wp_errors;
    }
    if ($user = get_user_by('login', $login)) {
        $user_data = get_userdata($user->ID);
        $roles = $user_data->roles;
        $role = array_shift($roles);
        if ($role == 'need-confirm') {
            $wp_errors->add('rcl_login_confirm', __('Your email is not confirmed!', 'wp-recall'));
            return $wp_errors;
        }
    }
    $creds = array();
    $creds['user_login'] = $login;
    $creds['user_password'] = $pass;
    $creds['remember'] = $member;
    $user = wp_signon($creds, false);
    if (is_wp_error($user)) {
        $wp_errors = $user;
        return $wp_errors;
    } else {
        rcl_update_timeaction_user();
        wp_redirect(rcl_get_authorize_url($user->ID));
        exit;
    }
}