将PHP登录迁移到Wordpress?

时间:2015-09-02 12:30:57

标签: wordpress

所以我使用Sessions使用自定义登录表格,我希望知道如何将其实现到wordpress中。

我已成功将数据库对象更改为wpdb方法但是我现在想知道如何在wordpress上实现会话?

是否有特定方式或者我可以创建会话变量并在重定向页面上检查该变量是否设置?

这是我目前的php登录代码,没有wpdb请记住我不会使用这些类:

$database = new MySQL();
$session = new Session($database);

$msg = '';
$msgl = '';
$msgemail = '';
$message = '';

if (isset($_POST['login']) && $session->isLogged == false) {

    $email = $database->escapeString($_POST['user_email']);
    $pass = sha1($database->escapeString($_POST['user_pass']));

    $result = $database->executeQuery("SELECT user_id, user_type from `user-tbl` WHERE `billing_email`='$email' AND `account_password`='$pass'");

    if ($database->numRows($result) == 1) {
        $row = $database->fetchResult($result);

        $_SESSION['account_id'] = $row['user_id'];
        $_SESSION['account_type'] = $row['user_type'];
        $_SESSION['security'] = hash('md5', $_SERVER['HTTP_USER_AGENT']);

        if (isset($_POST['store'])) {
            $_SESSION['store'] = 1;

            $session->storeCookie();
        } else {
            $_SESSION['store'] = 0;
        }

        $location = 'Location: ';
        if ($row['user_type'] == "customer") {
            $location .= '/account.php';
        } elseif ($row['user_type'] == "admin") {
            $location .= '/admin/account.php';
        } elseif ($row['user_type'] == "employee") {
            $location .= '/employee/account.php';
        }

        header($location, true);
    } else {
        $msg = "Please Enter Correct E-mail OR Password.";
    }
}

感谢您的投入!

0 个答案:

没有答案